SA Bugzilla – Bug 5464
SQLite user prefs: filehandle to database is not closed ('closing dbh with active statement handles')
Last modified: 2007-11-25 18:05:02 UTC
Spamassassin 3.2.0 Freebsd 6.2 p5-DBD-SQLite-1.13 sqlite3-3.3.16 We are using sqlite for user preferences only. The following error scrolls in the error log and if you do lsof |grep dbname the filehandles to the database never close. At somepoint the system will run out of filehandles (and probaly crash). Not sure if this has anything to do with Spamassassin/SQL.pm or if its a bug with sqlite or DBD-SqLite. Thanks. spamd[9824]: closing dbh with active statement handles at /usr/local/lib/perl5/site _perl/5.8.8/Mail/SpamAssassin/Conf/SQL.pm line 172, <GEN51> line 2
You'll likely never run out of FHs due to each child's life being limited to 200 messages. Have you actually seen that "At somepoint the system will run out of filehandles"? Nonetheless it's something to look into.
Try turning on autocommit in your connect string.
I added AutoCommit => 1 in /usr/local/lib/perl5/site_perl/5.8.8/Mail/SpamAssassin/Conf/SQL.PM on line 125. Average memory usage is about 400mb. I switched it to use sqlite and memory continues to go up (I stopped it at 2gig). Switched back to postgres and it works fine. There's some sort of memory leak somewhere. Any thoughts? Thanks guys.
You need to explicitly $sth->finish with SQLite. It's a bit of a bug in sqlite which I hope to fix in the future, but for now that should fix it.
/usr/local/lib/perl5/site_perl/5.8.8/Mail/SpamAssassin/Conf/SQL.pm does call $sth->finish line 163. Is it missing this somewhere else? Is it even a problem with /usr/local/lib/perl5/site_perl/5.8.8/Mail/SpamAssassin/Conf/SQL.pm thanks.
OK, so this might fix it: Index: lib/Mail/SpamAssassin/Conf/SQL.pm =================================================================== --- lib/Mail/SpamAssassin/Conf/SQL.pm (revision 539498) +++ lib/Mail/SpamAssassin/Conf/SQL.pm (working copy) @@ -165,6 +165,7 @@ else { die "config: SQL error: $sql\n".$sth->errstr."\n"; } + undef $sth; } else { die "config: SQL error: " . $dbh->errstr . "\n";
Hi, thanks. Tried that and it didnt work. Memory was up to 1.2Gig used in about 30 seconds. Switched the database back to postgres and average used memory is 400mb.
Moving items off the 3.2.1 queue to 3.2.2 to facilitate a quick release. If you can get this in Review status right away feel free to move it back
3.2.3 was released without these fixed, moving to 3.2.3
Created attachment 4181 [details] possible fix try this Mike
FYI, I wrote a t test that shows this and I'm look into why its happening now. Tried Daryl's fix but it is still showing up.
Created attachment 4194 [details] spamd_sql_prefs t test Here is the t test I'm working on, it doesn't currently pass due to this bug. If you want to try it out you'll need to add: run_sql_pref_tests=y to your t/config file.
Ok, I stand corrected, adding undef $sth does in fact fix it, I must have forgotten to run make or something before. Sending lib/Mail/SpamAssassin/Conf/SQL.pm Sending t/config.dist Adding t/spamd_sql_prefs.t Transmitting file data ... Committed revision 598107.