Date: Sun, 28 Nov 2010 17:22:38 +0200 From: Alex Samorukov <samm@os2.kiev.ua> To: FreeBSD-gnats-submit@FreeBSD.org Cc: apache@FreeBSD.org Subject: ports/152644: [PATCH] www/mod_log_mysql: [enable auto reconnect support] Message-ID: <E1PMj5K-000NAk-5y@s1.sdv.com.ua> Resent-Message-ID: <201011281550.oASFoAOw012118@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 152644 >Category: ports >Synopsis: [PATCH] www/mod_log_mysql: [enable auto reconnect support] >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Nov 28 15:50:09 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Alex Samorukov >Release: FreeBSD 7.3-RELEASE-p1 i386 >Organization: Net-Art >Environment: System: FreeBSD s1.sdv.com.ua 7.3-RELEASE-p1 FreeBSD 7.3-RELEASE-p1 #6: Sun Sep 5 17:57:21 EEST >Description: I am using mod_log_mysql on a busy web server and found that sometime i am gettng messages like "server gone away". In worst case i am also getting core dump in mysql_real_escape(), probably because db object is not valid anymore. After debugging I found that root reason is disconnect timeout - when child is not active for a long time server closing connection. This small patch enable auto-reconnect support, so in this case conection is re-established automatically. I tested it ~4 days and found that messages are gone and no more core dumps in the logs. Changed files: - Makefile - distinfo New file: - files/patch-mod_log_mysql.c Port maintainer (apache@FreeBSD.org) is cc'd. Generated with FreeBSD Port Tools 0.99 >How-To-Repeat: >Fix: --- ap20-mod_log_mysql-1.0_1.patch begins here --- diff -ruN --exclude=CVS /usr/ports/www/mod_log_mysql/Makefile /root/tmp/mod_log_mysql/Makefile --- /usr/ports/www/mod_log_mysql/Makefile 2009-05-17 10:24:32.000000000 +0300 +++ /root/tmp/mod_log_mysql/Makefile 2010-11-28 17:06:57.000000000 +0200 @@ -7,6 +7,7 @@ PORTNAME= mod_log_mysql PORTVERSION= 1.0 +PORTREVISION= 1 CATEGORIES= www # Original location: http://bitbrook.de/software/mod_log_mysql/mod_log_mysql.c MASTER_SITES= http://sheepkiller.nerim.net/ports/${PORTNAME}/ @@ -17,7 +18,7 @@ RUN_DEPENDS+= ${LOCALBASE}/${APACHEMODDIR}/mod_log_config-st.so:${PORTSDIR}/www/mod_log_config-st -MAKE_JOBS_SAFE= yes +MAKE_JOBS_SAFE= yes USE_APACHE= 20+ AP_FAST_BUILD= YES diff -ruN --exclude=CVS /usr/ports/www/mod_log_mysql/distinfo /root/tmp/mod_log_mysql/distinfo --- /usr/ports/www/mod_log_mysql/distinfo 2006-02-02 00:12:20.000000000 +0200 +++ /root/tmp/mod_log_mysql/distinfo 2010-11-28 17:04:42.000000000 +0200 @@ -1,3 +1,2 @@ -MD5 (apache2/mod_log_mysql-1.0.tar.gz) = bdde1ff13749437e2650fb4d376e2e5a SHA256 (apache2/mod_log_mysql-1.0.tar.gz) = 27fdd2c87133d62171a38585807f70009821a3cb13e011d2ceb62fcc1c8ad4bb SIZE (apache2/mod_log_mysql-1.0.tar.gz) = 8046 diff -ruN --exclude=CVS /usr/ports/www/mod_log_mysql/files/patch-mod_log_mysql.c /root/tmp/mod_log_mysql/files/patch-mod_log_mysql.c --- /usr/ports/www/mod_log_mysql/files/patch-mod_log_mysql.c 1970-01-01 03:00:00.000000000 +0300 +++ /root/tmp/mod_log_mysql/files/patch-mod_log_mysql.c 2010-11-28 17:01:37.000000000 +0200 @@ -0,0 +1,16 @@ +--- mod_log_mysql.c 2003-11-01 12:21:28.000000000 +0200 ++++ mod_log_mysql.c.new 2010-11-28 17:01:06.000000000 +0200 +@@ -172,11 +172,13 @@ + { + mysql_log *l = param; + MYSQL *db; ++ my_bool do_reconnect = 1; + + db = apr_palloc(p, sizeof(MYSQL)); + + mysql_init(db); + mysql_options(db, MYSQL_READ_DEFAULT_GROUP, "mod_log_mysql"); ++ mysql_options(db, MYSQL_OPT_RECONNECT,&do_reconnect); + + if (! mysql_real_connect(db, l->host, l->user, l->passwd, l->database, l->port, l->socket, 0)) { + ap_log_perror(APLOG_MARK, APLOG_CRIT, 0, p, "log database %s: %s", l->uri, mysql_error(db)); --- ap20-mod_log_mysql-1.0_1.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1PMj5K-000NAk-5y>