(EJAB-764) - "If the relational database is started or restarted after ejabberd is started, ejabberd does not reopen the connexions pool."
I installed 2.0.3 with OTP R11B-0 and connected it to our Postgresql Db and all works fine, but when I restart postgresql without restarting ejabberd, ejabberd won't recognize that it's connection has been broken and fails all subsequent attempts by clients to login.
Here's what I changed in the cfg to connect to the Db.
{auth_method, odbc}{odbc_server, "DSN=mydsn;UID=myuser;PWD=mypassword;DATABASE=mydatabase"}
{mod_last_odbc, []},
{mod_offline_odbc, []},
{mod_roster_odbc, []},
{mod_vcard_odbc, []},
I also changed the followihg because I thought perhaps the reconnect doesn't happen until a keepalive is sent:
{odbc_keepalive_interval, 120}
Did I misconfigure something?
Did I misunderstand the issue? I notice that there is another issue (EJAB-246) that sounds related, "ODBC: Reconnect should be trigger by sql_query error code".
Thanks.
Works for me using mysql
I installed 2.0.3 with OTP R11B-0 and connected it to our Postgresql Db and all works fine,
Maybe R11B-0 is too old? You could try with R11B-5, or R12B-5, or anything newer if a package is available for your system.
If you are lazy to compile Erlang yourself and you want to know if the problem could be fixed by using a more recent Erlang version, you can try to install ejabberd using ejabberd 2.0.3 binary installer from ProcessOne. It includes Erlang R12B-5, ejabberd, mysql and pgsql drivers.
but when I restart postgresql without restarting ejabberd, ejabberd won't recognize that it's connection has been broken and fails all subsequent attempts by clients to login.
It reconnects correctly for me using mysql. I don't have a pgsql server to test.
{auth_method, odbc}{odbc_server, "DSN=mydsn;UID=myuser;PWD=mypassword;DATABASE=mydatabase"}
This syntax is wrong, and I'm sure ejabberd didn't start with such line in ejabberd.cfg
{odbc_keepalive_interval, 120}
I didn't need to change this option.
I installed ejabberd 2.0.3, Erlang/OTP R12B-5, mysql from ejabberd-modules SVN.
Configuration of ejabberd: the default, with this change:
{auth_method, odbc}. {odbc_server, {mysql, "localhost", "ejadb", "ejauser", "ejapass"}}.I create an account and login. All correct up to here.
Now I stop the MySQL server:
Immediately, ejabberd starts complaining in ejabberd.log:
... =ERROR REPORT==== 26-Feb-2009::09:49:58 === E(<0.711.0>:ejabberd_odbc:385) : mysql_conn: Failed connecting to "localhost":3306 : {error, "connect failed : {error,econnrefused}"} =ERROR REPORT==== 26-Feb-2009::09:49:58 === E(<0.710.0>:ejabberd_odbc:347) : MySQL connection failed: connect_failed Waiting 30 seconds before retrying... =ERROR REPORT==== 26-Feb-2009::09:49:58 === E(<0.646.0>:ejabberd_odbc:385) : mysql_conn: Received unknown signal, exiting =INFO REPORT==== 26-Feb-2009::09:49:58 === I(<0.646.0>:ejabberd_odbc:383) : Closing connection #Port<0.3662>: ok =ERROR REPORT==== 26-Feb-2009::09:49:58 === ** Generic server <0.645.0> terminating ** Last message in was {'DOWN',#Ref<0.0.0.9599>,process,<0.646.0>,normal} ** When Server state == {state,<0.646.0>,mysql} ** Reason for termination == ** connection_dropped =CRASH REPORT==== 26-Feb-2009::09:49:58 === crasher: pid: <0.645.0> registered_name: [] exception exit: connection_dropped in function gen_server:terminate/6 initial call: ejabberd_odbc:init/1 ancestors: [ejabberd_odbc_sup_localhost,ejabberd_sup,<0.38.0>] messages: [] links: [<0.308.0>] dictionary: [] trap_exit: false status: running heap_size: 233 stack_size: 23 reductions: 472 neighbours: =ERROR REPORT==== 26-Feb-2009::09:49:58 === E(<0.661.0>:ejabberd_odbc:385) : mysql_conn: Received unknown signal, exiting =INFO REPORT==== 26-Feb-2009::09:49:58 === I(<0.661.0>:ejabberd_odbc:383) : Closing connection #Port<0.3667>: okIf I logout and login again the Jabber client, it fails.
Then I start MySQL:
A few seconds later, ejabberd reports in ejabberd.log a lot of stuff, like:
=PROGRESS REPORT==== 26-Feb-2009::10:16:40 === supervisor: {local,ejabberd_odbc_sup_localhost} started: [{pid,<0.821.0>}, {name,5}, {mfa,{ejabberd_odbc,start_link,["localhost",30000]}}, {restart_type,transient}, {shutdown,brutal_kill}, {child_type,worker}]Now I login again correctly.
Could it be OTP R11B-0?
Thanks for your reply.
The ODBC connection syntax should be correct. You can see that same format in the .cfg under "ODBC compatible or MSSQL Server".
Unlike you, when I stop postgres, there are no error messages in the ejabberd.log
I'll compile R12B-5 and see if that makes a difference.
ODBC reconnection works.
It appears that the reconnection capability is built into the pgsql module and not the generic odbc module.
Once I included the pgsql modules and adjusted the config, it worked fine.
Thanks again for your comments.