[Mod_log_sql] permanent reconnections

Robert Schulze rs at bytecamp.net
Fri Feb 15 08:59:58 EST 2008


Hi,

I've now added some more debugging output to mod_log_sql.c and 
mod_log_sql_mysql.c. As you can see

- log_sql_close_link() issues a message, when it is called, and whether 
the db-link is up.
- log_sql_mysql_close() issues a message, when it is called

Here is a bit output from the httpd-error.log

8<--------------------------------------------------------------------

[Fri Feb 15 14:37:27 2008] [error] log_sql_close_link called(), db 
connected: 1
[Fri Feb 15 14:37:27 2008] [error] log_sql_mysql_close()
[Fri Feb 15 14:37:28 2008] [error] mysql_query returned (1)
[Fri Feb 15 14:37:28 2008] [error] log_sql_mysql_close()
[Fri Feb 15 14:37:28 2008] [notice] db reconnect successful
[Fri Feb 15 14:37:28 2008] [error] log_sql_close_link called(), db 
connected: 1
[Fri Feb 15 14:37:28 2008] [error] log_sql_mysql_close()
[Fri Feb 15 14:37:30 2008] [error] log_sql_close_link called(), db 
connected: 1
[Fri Feb 15 14:37:30 2008] [error] log_sql_mysql_close()
[Fri Feb 15 14:37:30 2008] [error] mysql_query returned (1)
[Fri Feb 15 14:37:30 2008] [error] log_sql_mysql_close()
[Fri Feb 15 14:37:30 2008] [notice] db reconnect successful
[Fri Feb 15 14:37:31 2008] [error] mysql_query returned (1)
[Fri Feb 15 14:37:31 2008] [error] log_sql_mysql_close()
[Fri Feb 15 14:37:31 2008] [notice] db reconnect successful
[Fri Feb 15 14:37:33 2008] [error] log_sql_close_link called(), db 
connected: 1
[Fri Feb 15 14:37:33 2008] [error] log_sql_mysql_close()
[Fri Feb 15 14:37:34 2008] [error] log_sql_close_link called(), db 
connected: 1
[Fri Feb 15 14:37:34 2008] [error] log_sql_mysql_close()
[Fri Feb 15 14:37:34 2008] [error] mysql_query returned (1)
[Fri Feb 15 14:37:34 2008] [error] log_sql_mysql_close()
[Fri Feb 15 14:37:34 2008] [notice] db reconnect successful

8<--------------------------------------------------------------------

What I realized is, that apr_pool_cleanup_register gets 
log_sql_close_links in both cleanup_hooks:

static void log_sql_child_init(apr_pool_t *p, server_rec *s)
{
/* ... */
apr_pool_cleanup_register(p, NULL, log_sql_close_link, log_sql_close_link);
/* ... */
}

I changed the second log_sql_close_link to apt_pool_cleanup_null and 
everything seemed to work well.

No connection gets broken during several requests, only when spare 
workers get assimilated.
The mysqladmin processlist is now smaller and one can see that 
connections to the mysql-server indeed get reused, which wasn't the case 
before.

Can anyone verify that behavior of apr_pool_cleanup_register() and agree 
with me?

with kind regards,
Robert Schulze



More information about the Mod_log_sql mailing list