[ejabberd] mnesia corruption with concurrent ejabberdctl usage

Konstantin Khomoutov flatworm at users.sourceforge.net
Mon Dec 28 22:33:42 MSK 2009

On Mon, 28 Dec 2009 20:08:05 +0100
Martin Langhoff <martin.langhoff at gmail.com> wrote:

>  - It is not safe to run many ejabberdctl instances because they
> always use the same "connection name"
>  - If we give a truly random connection name, no overlaps happen, but
> erl will leak handles/processes/whatever
Not really. In fact the "atom table" of the Erlang emulator running
ejabberd server might eventually overflow.
>  - So a small pool of names with some locking may work? Modern distros
> carry flock, so we could say (pseudo-shell):
>    CONNLOCKDIR=/var/lock/ejabberd/ejabberdctl
>    for CONNID in 1..$MAXCONNECTIONS; do
>        if flock -n "$CONNLOCKDIR/ctl-ejabberd-$CONNID at localhost" \
>            erl -sname "ctl-ejabberd-$CONNID at localhost" ... ; then
>            break
I think that the idea proposed by Brian Cully, namely to stick to
OS PIDs to generate unique names is OK.
Refer to discussions archived as [1] and [2].

Indeed, when preparing Debian package for 2.1.0, I implemented
a new command-line option for ejabberdctl, "--concurrent", which,
when specified turns on generation of unique node name for
the Erlang process started by ejabberdctl, and this unique name
is obtained by just appending the PID of the shell process
running ejabberdctl script to the node name.
Without the "--concurrent" command-line option, ejabberdctl
uses the same simple node name each time which is optimised for
manual runs of ejabberdctl. See [3] for details.

1. http://lists.jabber.ru/pipermail/ejabberd/2009-November/005456.html
2. http://lists.jabber.ru/pipermail/ejabberd/2009-November/005457.html
3. http://git.debian.org/?p=users/khomoutov-guest/pkg-ejabberd.git;a=commit;h=719e12b592ad45e82a62dc61c35678747343849b

More information about the ejabberd mailing list