The following issue has been RESOLVED. ====================================================================== http://www.dbmail.org/mantis/view.php?id=1011 ====================================================================== Reported By: rmoesbergen Assigned To: paul ====================================================================== Project: DBMail Issue ID: 1011 Category: Database layer Reproducibility: always Severity: crash Priority: normal Status: resolved target: Resolution: fixed Fixed in Version: ====================================================================== Date Submitted: 25-Jun-13 15:09 CEST Last Modified: 04-Jul-13 14:35 CEST ====================================================================== Summary: Bug in db_con_get crashes dbmail-imapd when db is down Description: There's a bug in db_con_get that causes a crash when no connections are available in the connection pool for longer than 30 seconds:
dm_db.c, line 241, function db_con_get: if (! c) { TRACE(TRACE_EMERG,"[%p] can't get a database connection from the pool! max [%d] size [%d] active [%d]", pool, ConnectionPool_getMaxConnections(pool), ConnectionPool_size(pool), ConnectionPool_active(pool)); } --->>> assert(c); --->>> Connection_setQueryTimeout(c, (int)db_params.query_timeout); TRACE(TRACE_DATABASE,"[%p] connection from pool", c); return c; } When c is NULL, either the assert fires (if asserts are enabled) or an exception is thrown by libzdb for passing NULL to Connection_setQueryTimeout. I'm using this modified version of db_con_get now for my tests, which works fine: Connection_T db_con_get(void) { int i=0, k=0; Connection_T c = NULL; while (!c) { c = ConnectionPool_getConnection(pool); if (c) break; if((int)(i % 5)==0) { TRACE(TRACE_ALERT, "Thread is having trouble obtaining a database connection. Try [%d]", i); k = ConnectionPool_reapConnections(pool); TRACE(TRACE_INFO, "Database reaper closed [%d] stale connections", k); } sleep(1); i++; } Connection_setQueryTimeout(c, (int)db_params.query_timeout); TRACE(TRACE_DATABASE,"[%p] connection from pool", c); return c; } db_con_get should always return a connection, no matter what, since almost all callers do not check for a NULL return value from this function... The only way to do that is to wait indefinately for a connection to be available, I think. ====================================================================== ---------------------------------------------------------------------- (0003537) paul (administrator) - 04-Jul-13 14:35 http://www.dbmail.org/mantis/view.php?id=1011#c3537 ---------------------------------------------------------------------- fixed in 87dcc4fbc5767727e6d183f647c604b6dcc7a17b Issue History Date Modified Username Field Change ====================================================================== 25-Jun-13 15:09 rmoesbergen New Issue 04-Jul-13 14:35 paul Note Added: 0003537 04-Jul-13 14:35 paul Assigned To => paul 04-Jul-13 14:35 paul Status new => resolved 04-Jul-13 14:35 paul Resolution open => fixed ====================================================================== _______________________________________________ Dbmail-dev mailing list Dbmail-dev@dbmail.org http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail-dev