[ejabberd] Disconnection from mysql database...

Adrian Almenar S. adrian at genexies.com
Fri Nov 3 14:51:15 MSK 2006

I have been checking and i found on mysql_conn.erl:

fetch(Pid, Query, From) ->
    fetch(Pid, Query, From, ?DEFAULT_STANDALONE_TIMEOUT).

fetch(Pid, Query, From, Timeout) when is_pid(Pid), is_list(Query) ->
    Self = self(),
    Pid ! {fetch, Query, From},
    case From of
        Self ->
            %% We are not using a mysql_dispatcher, await the response
                {fetch_result, Pid, Result} ->
            after Timeout ->
                    {error, "query timed out"}
        _ ->
            %% From is gen_server From, Pid will do gen_server:reply() when
it has an answer

The problem I explained on the email after happens because it gets a
Timeout, I traced it to the part where (error, "query timed out") gets
called. I don't know too much erlang to modify this function but if anyone
can help me or can guide me to where I can read so I can make it it will be
greatly appreciated. I think the correct way of working is if it gets a
timeout, try to close the old connection and start a new one.

You can see this happening by connecting an ejabberd server to a mysql
database server and putting an iptables rule avoiding all connections to
mysql port.

Kind Regards,

Adrian Almenar

-----Mensaje original-----
De: ejabberd-bounces at jabber.ru [mailto:ejabberd-bounces at jabber.ru] En nombre
de Adrian Almenar S.
Enviado el: martes, 31 de octubre de 2006 18:48
Para: ejabberd at jabber.ru
Asunto: [ejabberd] Disconnection from mysql database...

Hi everyone,

I've downloaded the latest release of ejabberd (1.1.2) and installed it on
Redhat ES4. Im actually having some problems with ejabberd because it gets
disconnected silently from the database and if it tries to access it again,
instead of establishing a new connection it will simply tell that cannot

This problem happens cause i have 2 mysql databases installed working in
clusterdb mode and load-balanced with keepalived. Keepalived has a 15 minute
persistence timeout but if in those 15 minutes the ejabberd server doesn't
talk to the database keepalived will drop the connection. Then ejabberd when
needs access to the DB connects again to the load balancer and sees the
connection was closed, it just fails, he doesn't try to connect again.

Is something im missing ?

I tried putting the persistence timeout to 60 minutes but this only will
delay the issue.

Any thoughts will be appreciated.

Kind Regards,

Adrian Almenar

ejabberd mailing list
ejabberd at jabber.ru

More information about the ejabberd mailing list