[ejabberd] change odbc supervisor related restart strategy and multiple odbc pools support

Eric Liang eric.l.2046 at gmail.com
Sun May 30 11:25:06 MSD 2010


Hi all,
Every time after I benchmarked ejabberd, new users can not login the
server( because I use ejabberd_auth_odbc module). It looks like the odbc
related processes can't bear the stress and crash though ejabberd looks
~fine~.

I checked the supervisor restart strategy, they are all transient but
permanent. Are they set designedly( why if this) or default? Maybe for a
server started with several auth_methods, one of them should exit but
restart when error occurs and the rest auth_method related processes
will handle the upcoming auth jobs? Anyway, at least in my case, never
stopped odbc connections are necessary. So I change them to permanent(
see attatchment: 0001-change-the-odbc-restart-strategy-to-permanent.patch ).

And at the same time, I noticed this error :

    =ERROR REPORT==== 2010-05-26 20:07:17 ===
    E(<0.31328.8>:ejabberd_sm:88) : {{case_clause,
                                      {error,
                                       {timeout,
                                        {sys,get_status,
                                         ['ejabberd_odbc_sup_xxxxxxxx.com',
                                          500]}}}},
                                     [{lists,any,2},
                                      {ejabberd_sm,route_message,3},
                                      {ejabberd_sm,route,3},
                                      {ejabberd_local,route,3},
                                      {ejabberd_router,route,3},
                                      {ejabberd_c2s,session_established2,2},
                                      {p1_fsm,handle_msg,10},
                                      {proc_lib,init_p_do_apply,3}]}
    when processing:
    {{jid,"15378827501274875546918114","xxxxxxxx.com","tsung",
                         
    "15378827501274875546918114","xxxxxxxx.com","tsung"},
                      {jid,"tsung167276","xxxxxxxx.com",[],"tsung167276",
                          "xxxxxxxx.com",[]},
                      {xmlelement,"message",
                         
    [{"id","714620"},{"to","tsung167276 at xxxxxxxx.com"}],
                          [{xmlelement,"body",[],
                               [{xmlcdata,
                                   
    <<"qxvmvtglimieyhemzlxcqxvmvtglimieyhemzlxcvtglimieyhemzlxc">>}]}]}}

In the module: ejabberd_odbc_sup , I found the reason. Every time one
process need to communicate with the db, it will first get a random
connection in the odbc pool by function: get_random_pid, which will call
get_pids first. The get_pids will use the sys:get_status( with a timeout
) to test the supervisor process' status. In my option, this is not
necessary for if you want an exception when the supervisor hobbles, the
supervisor:which_children will do the same thing, and also the
sys:get_status will embitter the server.

Anyway, it looks that only one process is overcharged to route all
requests to database. To handle this, I add the multiple pools support
for odbc and the corresponding configuration: odbc_pool_amount. (see the
attachment:
0003-add-multiple-pools-support-for-odbc-corresponding-co.patch ).
I set the default odbc_pool_amount to 2 in case someone wants a
lightweight server, and you can set to 5 or more, which should be
benchmark-driven :).

You would notice that I've changed the function:
ejabberd_odbc_sup:get_random_id, which will use random:uniform to get
the random instead erlang:phash(now(), X).  Just for identical with
ejabberd_odbc_sup:get_pids, though it is a little faster.

Hope this helps.

Cheers,
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.jabber.ru/pipermail/ejabberd/attachments/20100530/46b5643c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-change-the-odbc-restart-strategy-to-permanent.patch
Type: text/x-diff
Size: 1121 bytes
Desc: not available
URL: <http://lists.jabber.ru/pipermail/ejabberd/attachments/20100530/46b5643c/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-add-multiple-pools-support-for-odbc-corresponding-co.patch
Type: text/x-diff
Size: 5219 bytes
Desc: not available
URL: <http://lists.jabber.ru/pipermail/ejabberd/attachments/20100530/46b5643c/attachment-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: OpenPGP digital signature
URL: <http://lists.jabber.ru/pipermail/ejabberd/attachments/20100530/46b5643c/attachment.pgp>


More information about the ejabberd mailing list