Re: [vchkpw] [bug][patch] - vchkpw/vmysql and Mysql 5

2006-06-29 Thread Tom Collins

This patch is in the upcoming 5.4.17 release.

-Tom

On May 29, 2006, at 7:05 AM, Ron Gage wrote:

Greetings:

I don't know if anyone in here is encountering this problem (yet), but 
it has
been affecting me for the past few weeks - ever since I upgraded my 
MySQL
server to 5.0.19.  It took quite a bit of digging, but I believe I 
have found

the problem.

To describe the problem: when you run vpopmail in MySQL mode, with
courier-authdaemond and MySQL v5.0 or later, you will find that for 
the first 8
hours, everything works just fine, but after 8 hours, nobody will be 
able to
authenticate to the email server and you will see MySQL server has 
gone away

errors in the maillog.

The cause of the problem is that in MySQL 5.0 (and probably some 4.1 
releases),
MySQL implements a new timeout definition for connections, a timeout 
that
ignores traffic.  This timeout will shut down the socket thread from 
the MySQL

side.  The problem is that the client (vchkpw and friends) do not
know/understand about this timeout and socket termination so they 
continue on
in ignorate bliss until they try to send to the socket and find that 
it's no

longer valid - literally the server has gone away.

The fix is to simply destroy the internal flags and file handles 
related to that

socket, rebuild a new one, and try again.

The included patch (inline and attached) implements this fix.  Please 
note that
there doesn't appear to be any way at this time to disable the timeout 
feature

in MySQL.

Please feel free to comment, tear apart, beat up, or otherwise rip to 
shreads my

fix!



--
Ron Gage
(LPIC1 MCP A+ Net+)
Westland, Michigan



--- vmysql.c~   2006-05-29 10:17:20.0 -0400
+++ vmysql.c2006-05-29 10:17:20.0 -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 fine

for 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 to

drop 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))) {



This message was sent using IMP, the Internet Messaging Program.
vmysql.diff




Re: [vchkpw] [bug][patch] - vchkpw/vmysql and Mysql 5

2006-06-05 Thread ron

Tom:

Quoting Tom Collins [EMAIL PROTECTED]:

I already applied a patch to 5.4.16 that looks like it would take 
care of this condition, and it should be more universal in how it 
works.


Can someone with MySQL try 5.4.16 and see if it fixes the problem?  
If not, I'll look into adding Ron's patch.


That is what I am running here - 5.4.16.  Had the same problem - worked 
fine for

the first 8 hours, then started getting failed auth errors.  I minimized the
problem from the MySQL side by changing the interactive_timeout and
wait_timeout values to , but this obviously doesn't actually fix the
problem.  If the server is kicked for some reason (mysqladmin shutdown then
mysqld_safe), then the auth will still fail since the socket is destroyed.

Ron Gage




Tom

On Jun 4, 2006, at 7:12 AM, tonix (Antonio Nati) wrote:

Please DON'T underextimate this patch, and put it in vpopmail soon.

When you stop MySQL, all services working with vpopmail library and 
using permanent connections to MySQL (like courier-authdaemon) will 
stop working. You must restart them after any mysql failure.


With this patch, no need to restart any service of this kind. 
Services will reopen MySQL connections automatically!


Tonino

At 16.05 29/05/2006, you wrote:

Greetings:

I don't know if anyone in here is encountering this problem (yet), 
but it has

been affecting me for the past few weeks - ever since I upgraded my MySQL
server to 5.0.19.  It took quite a bit of digging, but I believe I 
have found

the problem.

To describe the problem: when you run vpopmail in MySQL mode, with
courier-authdaemond and MySQL v5.0 or later, you will find that for 
the first 8
hours, everything works just fine, but after 8 hours, nobody will 
be able to
authenticate to the email server and you will see MySQL server has 
gone away

errors in the maillog.

The cause of the problem is that in MySQL 5.0 (and probably some 
4.1 releases),

MySQL implements a new timeout definition for connections, a timeout that
ignores traffic.  This timeout will shut down the socket thread 
from the MySQL

side.  The problem is that the client (vchkpw and friends) do not
know/understand about this timeout and socket termination so they 
continue on
in ignorate bliss until they try to send to the socket and find 
that it's no

longer valid - literally the server has gone away.

The fix is to simply destroy the internal flags and file handles 
related to that

socket, rebuild a new one, and try again.

The included patch (inline and attached) implements this fix.  
Please note that
there doesn't appear to be any way at this time to disable the 
timeout feature

in MySQL.

Please feel free to comment, tear apart, beat up, or otherwise rip 
to shreads my

fix!



--
Ron Gage
(LPIC1 MCP A+ Net+)
Westland, Michigan



--- vmysql.c~   2006-05-29 10:17:20.0 -0400
+++ vmysql.c2006-05-29 10:17:20.0 -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 fine

for 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 to

drop 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))) {



This message was sent using IMP, the Internet Messaging Program.














This message was sent using IMP, the Internet Messaging Program.



Re: [vchkpw] [bug][patch] - vchkpw/vmysql and Mysql 5

2006-06-05 Thread Tom Collins

On Jun 5, 2006, at 7:37 AM, [EMAIL PROTECTED] wrote:
That is what I am running here - 5.4.16.  Had the same problem - 
worked fine for
the first 8 hours, then started getting failed auth errors.  I 
minimized the

problem from the MySQL side by changing the interactive_timeout and
wait_timeout values to , but this obviously doesn't actually 
fix the
problem.  If the server is kicked for some reason (mysqladmin 
shutdown then
mysqld_safe), then the auth will still fail since the socket is 
destroyed.


Thanks Ron, I'll get your patch into CVS and the 5.4.17 release and 
shoot for getting something up on SourceForge this week.


--
Tom Collins  -  [EMAIL PROTECTED]
Vpopmail - virtual domains for qmail: http://vpopmail.sf.net/
QmailAdmin - web interface for Vpopmail: http://qmailadmin.sf.net/



Re: [vchkpw] [bug][patch] - vchkpw/vmysql and Mysql 5

2006-06-04 Thread tonix (Antonio Nati)


Please DON'T underextimate this patch, and put it in vpopmail soon.

When you stop MySQL, all services working with vpopmail library and 
using permanent connections to MySQL (like courier-authdaemon) will 
stop working. You must restart them after any mysql failure.


With this patch, no need to restart any service of this kind. 
Services will reopen MySQL connections automatically!


Tonino

At 16.05 29/05/2006, you wrote:

Greetings:

I don't know if anyone in here is encountering this problem (yet), but it has
been affecting me for the past few weeks - ever since I upgraded my MySQL
server to 5.0.19.  It took quite a bit of digging, but I believe I have found
the problem.

To describe the problem: when you run vpopmail in MySQL mode, with
courier-authdaemond and MySQL v5.0 or later, you will find that for 
the first 8

hours, everything works just fine, but after 8 hours, nobody will be able to
authenticate to the email server and you will see MySQL server has gone away
errors in the maillog.

The cause of the problem is that in MySQL 5.0 (and probably some 4.1 
releases),

MySQL implements a new timeout definition for connections, a timeout that
ignores traffic.  This timeout will shut down the socket thread from the MySQL
side.  The problem is that the client (vchkpw and friends) do not
know/understand about this timeout and socket termination so they continue on
in ignorate bliss until they try to send to the socket and find that it's no
longer valid - literally the server has gone away.

The fix is to simply destroy the internal flags and file handles 
related to that

socket, rebuild a new one, and try again.

The included patch (inline and attached) implements this 
fix.  Please note that

there doesn't appear to be any way at this time to disable the timeout feature
in MySQL.

Please feel free to comment, tear apart, beat up, or otherwise rip 
to shreads my

fix!



--
Ron Gage
(LPIC1 MCP A+ Net+)
Westland, Michigan



--- vmysql.c~   2006-05-29 10:17:20.0 -0400
+++ vmysql.c2006-05-29 10:17:20.0 -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 fine

for 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 to

drop 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))) {



This message was sent using IMP, the Internet Messaging Program.






Re: [vchkpw] [bug][patch] - vchkpw/vmysql and Mysql 5

2006-06-04 Thread Tom Collins
I already applied a patch to 5.4.16 that looks like it would take care 
of this condition, and it should be more universal in how it works.


Can someone with MySQL try 5.4.16 and see if it fixes the problem?  If 
not, I'll look into adding Ron's patch.


Tom

On Jun 4, 2006, at 7:12 AM, tonix (Antonio Nati) wrote:

Please DON'T underextimate this patch, and put it in vpopmail soon.

When you stop MySQL, all services working with vpopmail library and 
using permanent connections to MySQL (like courier-authdaemon) will 
stop working. You must restart them after any mysql failure.


With this patch, no need to restart any service of this kind. Services 
will reopen MySQL connections automatically!


Tonino

At 16.05 29/05/2006, you wrote:

Greetings:

I don't know if anyone in here is encountering this problem (yet), 
but it has
been affecting me for the past few weeks - ever since I upgraded my 
MySQL
server to 5.0.19.  It took quite a bit of digging, but I believe I 
have found

the problem.

To describe the problem: when you run vpopmail in MySQL mode, with
courier-authdaemond and MySQL v5.0 or later, you will find that for 
the first 8
hours, everything works just fine, but after 8 hours, nobody will be 
able to
authenticate to the email server and you will see MySQL server has 
gone away

errors in the maillog.

The cause of the problem is that in MySQL 5.0 (and probably some 4.1 
releases),
MySQL implements a new timeout definition for connections, a timeout 
that
ignores traffic.  This timeout will shut down the socket thread from 
the MySQL

side.  The problem is that the client (vchkpw and friends) do not
know/understand about this timeout and socket termination so they 
continue on
in ignorate bliss until they try to send to the socket and find that 
it's no

longer valid - literally the server has gone away.

The fix is to simply destroy the internal flags and file handles 
related to that

socket, rebuild a new one, and try again.

The included patch (inline and attached) implements this fix.  Please 
note that
there doesn't appear to be any way at this time to disable the 
timeout feature

in MySQL.

Please feel free to comment, tear apart, beat up, or otherwise rip to 
shreads my

fix!



--
Ron Gage
(LPIC1 MCP A+ Net+)
Westland, Michigan



--- vmysql.c~   2006-05-29 10:17:20.0 -0400
+++ vmysql.c2006-05-29 10:17:20.0 -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 fine

for 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 to

drop 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))) {



This message was sent using IMP, the Internet Messaging Program.










Re: [vchkpw] [bug][patch] - vchkpw/vmysql and Mysql 5

2006-06-04 Thread Jianbin Xiao
Jianbin Xiao- vmysql: reconnect to server if connection was dropped.This patch can resolv this program. On 5/29/06, 
Ron Gage [EMAIL PROTECTED] wrote:Greetings:
I don't know if anyone in here is encountering this problem (yet), but it hasbeen affecting me for the past few weeks - ever since I upgraded my MySQLserver to 5.0.19.It took quite a bit of digging, but I believe I have found
the problem.To describe the problem: when you run vpopmail in MySQL mode, withcourier-authdaemond and MySQL v5.0 or later, you will find that for the first 8hours, everything works just fine, but after 8 hours, nobody will be able to
authenticate to the email server and you will see MySQL server has gone awayerrors in the maillog.The cause of the problem is that in MySQL 5.0 (and probably some 4.1 releases),MySQL implements a new timeout definition for connections, a timeout that
ignores traffic.This timeout will shut down the socket thread from the MySQLside.The problem is that the client (vchkpw and friends) do notknow/understand about this timeout and socket termination so they continue on
in ignorate bliss until they try to send to the socket and find that it's nolonger valid - literally the server has gone away.The fix is to simply destroy the internal flags and file handles related to that
socket, rebuild a new one, and try again.The included patch (inline and attached) implements this fix.Please note thatthere doesn't appear to be any way at this time to disable the timeout featurein MySQL.
Please feel free to comment, tear apart, beat up, or otherwise rip to shreads myfix!--Ron Gage(LPIC1 MCP A+ Net+)Westland, Michigan--- vmysql.c~ 2006-05-29 10:17:20.0
 -0400+++ vmysql.c2006-05-29 10:17:20.0 -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 issuch a thing+as a connection timeout regardless of activity.By default under MySQL5, 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 secondattempt+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 isalways 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))) {This message was sent using IMP, the Internet Messaging Program.
-- ===Jianbin Xiaohttp://www.xiaojb.com===


[vchkpw] [bug][patch] - vchkpw/vmysql and Mysql 5

2006-05-29 Thread Ron Gage
Greetings:

I don't know if anyone in here is encountering this problem (yet), but it has
been affecting me for the past few weeks - ever since I upgraded my MySQL
server to 5.0.19.  It took quite a bit of digging, but I believe I have found
the problem.

To describe the problem: when you run vpopmail in MySQL mode, with
courier-authdaemond and MySQL v5.0 or later, you will find that for the first 8
hours, everything works just fine, but after 8 hours, nobody will be able to
authenticate to the email server and you will see MySQL server has gone away
errors in the maillog.

The cause of the problem is that in MySQL 5.0 (and probably some 4.1 releases),
MySQL implements a new timeout definition for connections, a timeout that
ignores traffic.  This timeout will shut down the socket thread from the MySQL
side.  The problem is that the client (vchkpw and friends) do not
know/understand about this timeout and socket termination so they continue on
in ignorate bliss until they try to send to the socket and find that it's no
longer valid - literally the server has gone away.

The fix is to simply destroy the internal flags and file handles related to that
socket, rebuild a new one, and try again.

The included patch (inline and attached) implements this fix.  Please note that
there doesn't appear to be any way at this time to disable the timeout feature
in MySQL.

Please feel free to comment, tear apart, beat up, or otherwise rip to shreads my
fix!



-- 
Ron Gage
(LPIC1 MCP A+ Net+)
Westland, Michigan



--- vmysql.c~   2006-05-29 10:17:20.0 -0400
+++ vmysql.c2006-05-29 10:17:20.0 -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 fine
for 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 to
drop 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))) {



This message was sent using IMP, the Internet Messaging Program.
--- vmysql.c~	2006-05-29 10:17:20.0 -0400
+++ vmysql.c	2006-05-29 10:17:20.0 -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 fine for 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 to drop 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 =