5547
2007-07-04 07:14:17 +0000
calculate_expire_delta return value in BayesStore SQL.pm causes Perl warning
2007-09-28 17:59:14 +0000
1
1
1
Unclassified
Spamassassin
spamassassin
SVN Trunk (Latest Devel Version)
Other
All
NEW
P5
trivial
Undefined
1
peter
dev
0
oldest_to_newest
37932
0
peter
2007-07-04 07:14:17 +0000
The calculate_expire_delta function in BayesStore/SQL.pm can return undef,
which creates a warning (turns up in procmail logs):
warn: Odd number of elements in hash assignment at BayesStore.pm line 322.
warn: Use of uninitialized value in list assignment at BayesStore.pm line 322.
It should probably return an empty hash at that point (as per the patch), since
%delta may have information in it by that stage which we don't want to return,
since the function didn't complete.
Also need to make sure that the expected behaviour of "return 0 unless
(%delta);" is maintained in BayesStore.pm, after this call is made:
my %delta = $self->calculate_expire_delta($vars[10], $start, $max_expire_mult);
Relevant dbg output - note the trigger is the SQL connection going away (not
sure why, since the email still gets scored with bayes):
[32655] dbg: bayes: can't use estimation method for expiry, unexpected result,
calculating optimal atime delta (first pass)
[32655] dbg: bayes: expiry max exponent: 9
[32655] dbg: bayes: calculate_expire_delta: SQL error: Lost connection to MySQL
server during query
[32655] warn: Odd number of elements in hash assignment at /perl/lib/Mail/
SpamAssassin/BayesStore.pm line 322.
[32655] warn: Use of uninitialized value in list assignment at /perl/lib/Mail/
SpamAssassin/BayesStore.pm line 322.
[32655] dbg: bayes: atime token reduction
[32655] dbg: bayes: ======== ===============
[32655] dbg: bayes: 43200 0
[32655] dbg: bayes: 86400 0
[32655] dbg: bayes: 172800 0
[32655] dbg: bayes: 345600 0
[32655] dbg: bayes: 691200 0
[32655] dbg: bayes: 1382400 0
[32655] dbg: bayes: 2764800 0
[32655] dbg: bayes: 5529600 0
[32655] dbg: bayes: 11059200 0
[32655] dbg: bayes: 22118400 0
[32655] dbg: bayes: couldn't find a good delta atime, need more token
difference, skipping expire
[32655] dbg: bayes: set_last_expire: SQL error: MySQL server has gone away
[32655] dbg: bayes: remove_running_expire_tok: SQL error: MySQL server has gone
away
[32655] dbg: bayes: expiry completed
Output of sa-learn --dump magic for reference:
0.000 0 3 0 non-token data: bayes db version
0.000 0 3215 0 non-token data: nspam
0.000 0 5188 0 non-token data: nham
0.000 0 174856 0 non-token data: ntokens
0.000 0 1163584595 0 non-token data: oldest atime
0.000 0 1183554698 0 non-token data: newest atime
0.000 0 0 0 non-token data: last journal sync atime
0.000 0 1183472725 0 non-token data: last expiry atime
0.000 0 13725329 0 non-token data: last expire atime delta
0.000 0 0 0 non-token data: last expire reduction
count
37933
1
4031
peter
2007-07-04 07:16:36 +0000
Created attachment 4031
Change return value of BayesStore/SQL.pm::calculate_expire_delta to empty hash
38767
2
peter
2007-09-28 17:59:14 +0000
If possible, could this trivial patch be reviewed for 3.2.4? In the mean time I
have been manually patching local installations and the patch resolves the
warning. See also #5661 related to SQL.pm. Cheers.
(In reply to comment #0)
> The calculate_expire_delta function in BayesStore/SQL.pm can return undef,
> which creates a warning (turns up in procmail logs):
> warn: Odd number of elements in hash assignment at BayesStore.pm line 322.
> warn: Use of uninitialized value in list assignment at BayesStore.pm line 322.
>
> It should probably return an empty hash at that point (as per the patch), since
> %delta may have information in it by that stage which we don't want to return,
> since the function didn't complete.
>
> Also need to make sure that the expected behaviour of "return 0 unless
> (%delta);" is maintained in BayesStore.pm, after this call is made:
> my %delta = $self->calculate_expire_delta($vars[10], $start, $max_expire_mult);
>
4031
2007-07-04 07:16:36 +0000
2007-07-04 07:16:36 +0000
Change return value of BayesStore/SQL.pm::calculate_expire_delta to empty hash
patch
text/plain
459
peter
SW5kZXg6IGxpYi9NYWlsL1NwYW1Bc3Nhc3Npbi9CYXllc1N0b3JlL1NRTC5wbQo9PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
Ci0tLSBsaWIvTWFpbC9TcGFtQXNzYXNzaW4vQmF5ZXNTdG9yZS9TUUwucG0gICAgIChyZXZpc2lv
biA1NTMyMDgpCisrKyBsaWIvTWFpbC9TcGFtQXNzYXNzaW4vQmF5ZXNTdG9yZS9TUUwucG0gICAg
ICh3b3JraW5nIGNvcHkpCkBAIC0yNTQsNyArMjU0LDcgQEAKIAogICAgIHVubGVzcyAoJHJjKSB7
CiAgICAgICBkYmcoImJheWVzOiBjYWxjdWxhdGVfZXhwaXJlX2RlbHRhOiBTUUwgZXJyb3I6ICIu
JHNlbGYtPntfZGJofS0+ZXJyc3RyKCkpOwotICAgICAgcmV0dXJuIHVuZGVmOworICAgICAgcmV0
dXJuICgpOwogICAgIH0KIAogICAgIG15ICgkY291bnQpID0gJHN0aC0+ZmV0Y2hyb3dfYXJyYXko
KTsK