From c291c20a3b8350a6960311afc8f08923c4b40d47 Mon Sep 17 00:00:00 2001 From: Badlop Date: Fri, 22 Nov 2024 19:13:46 +0100 Subject: [PATCH] Fix problem starting ejabberd when first host uses SQL, other one mnesia The problem appeared when there are several vhosts, the first vhost uses SQL for persistent data (and RAM for volatile), and another vhost wants to use Mnesia Example config to trigger the problem: hosts: - mysql.localhost - localhost host_config: mysql.localhost: default_db: sql In that case, ejabberd crashed at start with an error like: [critical] Internal error of module mod_muc has occurred during start: ... ** exception exit: {aborted, {no_exists, [muc_room, [{{muc_room,{'_',<<"conference.localhost">>},'_'}, [], ['$_']}]]}} --- src/mod_muc_mnesia.erl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mod_muc_mnesia.erl b/src/mod_muc_mnesia.erl index 5be5b7928..d5a89b36d 100644 --- a/src/mod_muc_mnesia.erl +++ b/src/mod_muc_mnesia.erl @@ -57,6 +57,10 @@ init(Host, Opts) -> transient, 5000, worker, [?MODULE]}, case supervisor:start_child(ejabberd_backend_sup, Spec) of {ok, _Pid} -> ok; + %% Maybe started for a vhost which only wanted mnesia for ram + %% and this vhost wants mnesia for persitent storage too + {error, {already_started, _Pid}} -> + init([Host, Opts]); Err -> Err end.