Erlang Mailing Lists

Author Message

<  Ejabberd mailing list  ~  Disconnection from mysql database...

Guest
Posted: Tue Nov 28, 2006 4:18 pm Reply with quote
Guest
After some time trying to solve this problem, i have made some changes that
allow ejabberd using a load balanced mysql cluster to reconnect to another
database when 1 goes down. I have made this change on the code maybe it can
help a little bit fro future release.

By the way im no Erlang-Proficient programmer so any changes would be
welcome. Wink

Kind Regards,

Adrian Almenar


Index: odbc/ejabberd_odbc.erl
===================================================================
--- odbc/ejabberd_odbc.erl (revision 683)
+++ odbc/ejabberd_odbc.erl (working copy)
@@ -132,12 +132,18 @@
%% {stop, Reason, State} (terminate/2 is called)
%%----------------------------------------------------------------------
handle_call({sql_query, Query}, _From, State) ->
- Reply = sql_query_internal(State, Query),
- {reply, Reply, State};
+ try Reply = sql_query_internal(State, Query),
+ {reply, Reply, State}
+ catch
+ error:ErrorMsg -> {stop, ErrorMsg, State}
+ end;

handle_call({sql_transaction, F}, _From, State) ->
- Reply = execute_transaction(State, F, ?MAX_TRANSACTION_RESTARTS),
- {reply, Reply, State};
+ try Reply = execute_transaction(State, F, ?MAX_TRANSACTION_RESTARTS),
+ {reply, Reply, State}
+ catch
+ error:ErrorMsg -> {stop, ErrorMsg, State}
+ end;

handle_call(_Request, _From, State) ->
Reply = ok,
@@ -276,7 +282,7 @@
{error, Reason} ->
?ERROR_MSG("MySQL connection failed: ~p~n", [Reason]),
%% If we can't connect we wait for 30 seconds before retrying
- timer:sleep(30000),
+ timer:sleep(1000),
{stop, mysql_connection_failed}
end.


Kind Regards

-----Mensaje original-----
De: ejabberd-bounces@jabber.ru [mailto:ejabberd-bounces@jabber.ru] En nombre
de Adrian Almenar S.
Enviado el: martes, 31 de octubre de 2006 18:48
Para: ejabberd@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
connect.

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@jabber.ru
http://lists.jabber.ru/mailman/listinfo/ejabberd



Post recived from mailinglist
yeti
Posted: Sat Sep 01, 2012 5:56 am Reply with quote
User Joined: 01 Sep 2012 Posts: 17 Location: fgf
cheap designer *beep* are the most suitable accessories for women who are fond of attending parties.There are different style in our cheap *beep* shop.cheap purses are a kind of practical products and are full of vitality.If you can choose cheap designer bags right now, we can supply all kinds of cheap bags from stock.
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum