Bug 4670 - [review] sa-learn: Fails on --restore using sdbm
Summary: [review] sa-learn: Fails on --restore using sdbm
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Learner (show other bugs)
Version: unspecified
Hardware: Other other
: P5 normal
Target Milestone: 3.1.1
Assignee: SpamAssassin Developer Mailing List
URL: http://bugs.debian.org/cgi-bin/bugrep...
Whiteboard: ready for commit
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-08 00:26 UTC by spamassassin
Modified: 2005-12-19 08:25 UTC (History)
0 users



Attachment Type Modified Status Actions Submitter/CLA Status
Patch File patch None Michael Parker [HasCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description spamassassin 2005-11-08 00:26:34 UTC
sa-learn tries to rename bayes_seen.convertPID to bayes_seen, but the SDBM
backend creates bayes_seen.convertPID.pag and bayes_seen.convertPID.dir
instead.

----------------------------------

got bit by this one as well.

[22472] dbg: bayes: tie-ing to DB file R/W /home/kevint/.spamassassin/bayes_toks
[22472] dbg: bayes: tie-ing to DB file R/W /home/kevint/.spamassassin/bayes_seen
[22472] dbg: bayes: found bayes db version 3
[22472] dbg: bayes: untie-ing
[22472] dbg: bayes: untie-ing db_toks
[22472] dbg: bayes: untie-ing db_seen
[22472] dbg: bayes: files locked, now unlocking lock
[22472] dbg: locker: safe_unlock: unlocked /home/kevint/.spamassassin/bayes.mutex
[22472] dbg: bayes: error while renaming
/home/kevint/.spamassassin/bayes_toks.convert22472 to
/home/kevint/.spamassassin/bayes_toks: No such file or directory
Comment 1 Matt Kettler 2005-12-14 22:08:07 UTC
For what it's worth, I just ran into this myself.

It seems the fundamental problem is that sa-learn --restore is unaware of the
.dir and .pag files used by SDBM, and thinks it uses the same single-file format
that DB_File uses.

So it's trying to rename bayes_toks.convert<PID> -> bayes_toks and
bayes_seen.convert<PID> -> bayes_seen

Really it should be trying to rename:
bayes_toks.convert<PID>.dir -> bayes_toks.dir
bayes_toks.convert<PID>.pag -> bayes_toks.pag

bayes_seen.convert<PID>.dir -> bayes_seen.dir
bayes_seen.convert<PID>.pag -> bayes_seen.pag


As a short-term workaround, I was able to use sa-learn --restore and manually
rename the failed files to their correct names and everything worked fine from
there on. 

However, if you're going to do this manual move, make sure  to back up the
existing files and make no SA processes are running, as there's no locking or
mutexes here. If another SA process was to update the DB as you were copying,
corruption could easily result.

Comment 2 Michael Parker 2005-12-14 23:18:29 UTC
the restore_database subroutine makes some assumptions, incorrectly, about the
file extensions.  We'll either need to just override the restore stuff or fix it
up so that it is more aware of the fact that SDBM can have multiple
files/extensions.
Comment 3 Michael Parker 2005-12-19 06:00:09 UTC
Created attachment 3310 [details]
Patch File

Creates a couple of little helper methods to allow for proper unlinking and
renaming.
Comment 4 Michael Parker 2005-12-19 06:00:44 UTC
Ready for review for 3.1.1
Comment 5 Justin Mason 2005-12-19 08:19:01 UTC
+1
Comment 6 Sidney Markowitz 2005-12-19 10:20:38 UTC
+1
Comment 7 Michael Parker 2005-12-19 17:25:40 UTC
Now fixed in trunk and 3.1 branch.