mysql gone away - daily?

Started by D3s7, December 19, 2006, 08:19:17 AM

Previous topic - Next topic

D3s7

I'm not sure if this is a config problem or issue with my machine but it seems daily I'm getting the "mysql has gone away" message whenver someone tries to authenticate with IMAP.

The weird twist about this is if I stop the authdaemon and mysql then restart them BOTH, it works for the rest of the day then repeats the next morning.

I can manually connect and query the DB which makes me think something with the authdaemon however, just stopping and restarting it doesn't fix the problem... both it and mysql must be stopped and restarted.

Is there any other config files that I could be missing or a debug setting I can turn on to see where/when/why this would be happening daily?

jerm

sounds reminiscent of this issue:

There's an issue with the vpopmail mysql interface on mysql5 that requires a patch to ahve auth connections work properly

This is up to at least vpopmail-5.4.13

below is a patch for vmysql.c to work around it


--- vmysql.c~   2006-05-29 10:17:20.000000000 -0400
+++ vmysql.c    2006-05-29 10:17:20.000000000 -0400
@@ -465,7 +465,31 @@
);
     if (mysql_query(&mysql_read,SqlBufRead)) {
         fprintf(stderr, "vmysql: sql error[3]: %s\n", mysql_error(&mysql_read));
-        return(NULL);
+        /* Ron Gage - May 29, 2006 - With newer versions of MySQL, there is such a thing
+ as a connection timeout regardless of activity. By default under MySQL 5, this
+        timeout is 28800 seconds (8 hours).  If your vpopmail system runs finefor the
+        first 8 hours, then stops authenticating, this timeout is your problem (especially
+        under authdaemond).
+
+        What this code does is when an error is encountered, it first tries todrop and
+ rebuild a connection to the SQL server and tries again. If this second attempt
+ fails, then something other than the connection timeout is the problem.  This fix
+ need to be implemented in other places but in my setup (Slackware 10.2, netqmail,
+ vpopmail, courier-authdaemond, courier-imapd and a few others), this is always where
+        the auth attempt died with a "SQL server has gone away" error.
+        */
+
+        fprintf(stderr, "Attempting to rebuild connection to SQL server\n");
+        vclose();
+        verrori = 0;
+        if ( (err=vauth_open_read()) != 0 ) {
+          verrori = err;
+          return(NULL);
+        }
+        if (mysql_query(&mysql_read, SqlBufRead)) {
+          fprintf (stderr, "vmysql: connection rebuild failed: %s\n", mysql_error(&mysql_read));
+          return(NULL);
+         }
     }

     if (!(res_read = mysql_store_result(&mysql_read))) {

D3s7

ah great... Thank you !

I missed that patch when I was doing a search...

xela

Quote from: D3s7 on December 20, 2006, 07:16:22 AM
ah great... Thank you !

I missed that patch when I was doing a search...

I seem to be having the same problem but it happens every 5 minutes, and the patch hasnt helped. Any ideas anyone?

matt

Yes, use MySQL 4, or get rid of authdaemon headaches forever and use dovecot as the IMAP server instead. :-)

Dovecot installs quite easily. Configuring it can be bothersome b/c the docs aren't great. But I'll attach a working example for you.

xela

Yeh I decided to downgrade MYSQL late last night, just finished it now, looking promising.

Cheers

D3s7

interesting thing i dovecat has the came problem w/ vmysql :)


Mar 21 08:23:00 mailrbl2 dovecot: auth(default): vmysql: sql error[3]: MySQL server has gone away


haven't patched this one yet as you can tell

D3s7

#7
interestingly enough, vpopmail 5.4.17 has the patch already in place but the problem is still there...

EDIT: my fauilt.... the toaster-watcher.conf was still set to use 5.4.13 which is NOT patched... - changed to use the port.. hopefully that fixes it