[Dovecot] dovecot behaving badly after upgrade..

Adrian Vasile yoyo at opennet.ro
Wed Dec 28 20:50:20 EET 2005


wrote it and tested it. now it reconnects to mysql as it should.

<snip>
loki ~ # cat /usr/local/portage/net-mail/dovecot/files/db-mysql.diff
diff -ur dovecot-0.99.14-orig/src/auth/db-mysql.c 
dovecot-0.99.14/src/auth/db-mysql.c
--- dovecot-0.99.14-orig/src/auth/db-mysql.c    2004-12-19 
07:25:15.000000000 +0200
+++ dovecot-0.99.14/src/auth/db-mysql.c 2005-12-27 15:43:11.000000000 +0200
@@ -72,6 +72,9 @@
                case CR_SERVER_GONE_ERROR:
                case CR_SERVER_LOST:
                        /* connection lost - try immediate reconnect */
+                       /* but first close the connection :) */
+                       if (conn->connected)
+                               mysql_conn_close(conn);
                        if (!mysql_conn_open(conn))
                                break;
                        if (mysql_query(conn->mysql, query) == 0) {
</snip>

i suppose that v1alpha5 has the same bug.. addapt to needs

Adrian Vasile wrote:

> re,re
>
> I think I found the issue:
> in this switch :
>        if (failed) {
>                /* query failed */
>                switch (mysql_errno(conn->mysql)) {
>                case CR_SERVER_GONE_ERROR:
>                case CR_SERVER_LOST:
>                        /* connection lost - try immediate reconnect */
>                        if (!mysql_conn_open(conn))
>                                break;
>                        if (mysql_query(conn->mysql, query) == 0) {
>                                failed = FALSE;
>                                break;
>                        }
>                        /* query failed, fallback to error handler */
>                default:
>                        i_error("MySQL: Error executing query \"%s\": %s",
>                                query, mysql_error(conn->mysql));
>                        break;
>                }
>        }
> if this error occurs then reconnect.. this is true, but
> static int mysql_conn_open(struct mysql_connection *conn)
> {
>        if (conn->connected)
>                return TRUE;
> ....
> in the conn structure the connected bit is always true I belive.
>
> May I write the patch ?
>
> Adrian Vasile wrote:
>
>> Hi,
>>
>> It doesn't matter who's fault it is. I run Dovecot with mysql auth and
>> it does the same..
>> the idea is that mysql has a timeout for connections so, after a period
>> of inactivity it closes the connection.
>> I don't know if Dovecot uses what the developers from mysql propose:
>> if mysql_ping != ok then reconnect
>> I didn't have time to browse the sources.
>>
>> The lazy work-around I made is modifying the pop3/imap monitor of mon
>> and every 15 min, mon logs into dovecot
>> with a test account :)
>>
>> It's the same problem with amavis but that's not necesarly amavis's
>> fault but the DBI people.
>>
>> PS: I run :
>> * net-mail/dovecot
>>     Installed:           0.99.14-r1
>>     Homepage:            http://dovecot.org/
>>     Description:         An IMAP and POP3 server written with security
>> primarily in mind
>>
>> * dev-db/mysql
>>     Installed:           5.0.17
>>     Homepage:            http://www.mysql.com/
>>     Description:         A fast, multi-threaded, multi-user SQL
>> database server
>>
>> maybe using pam_mysql would solve this issue..
>>
>> daniel petre wrote:
>>
>>>
>>> i dont think its vpopmail's fault, since THIS running version is OKAY:
>>>
>>> delfix ~ # emerge -s dovecot
>>> Searching...
>>> [ Results for search key : dovecot ]
>>> [ Applications found : 1 ]
>>>
>>> *  net-mail/dovecot
>>>       Latest version available: 1.0_alpha5
>>>       Latest version installed: 0.99.14-r1
>>>       Size of downloaded files: 1,236 kB
>>>       Homepage:    http://dovecot.org/
>>>       Description: An IMAP and POP3 server written with security 
>>> primarily in mind
>>>       License:     LGPL-2.1
>>>
>>>
>>>
>>> Timo Sirainen wrote:
>>>
>>>> On Sun, 2005-12-18 at 02:52 +0200, daniel petre wrote:
>>>>
>>>>> dovecot: Dec 18 03:42:08 Error: auth(default): vmysql: sql 
>>>>> error[3]: MySQL server has gone away
>>>>
>>>>
>>>>
>>>>
>>>> ..
>>>>
>>>>> anyone encountered this?
>>>>> mysql is not away, i edited dovecot.conf carefully.
>>>>> what am i missing?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> That error message is coming from vpopmail libraries, and it looks 
>>>> like
>>>> it at least thinks it can't connect to MySQL. Looks to me like the
>>>> problem is in vpopmail's side. There isn't really anything that can be
>>>> configured for vpopmail from Dovecot's side.
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>>
>



More information about the dovecot mailing list