[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

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,
    when processing:
    [{"id","714620"},{"to","tsung167276 at xxxxxxxx.com"}],

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
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.

-------------- 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