From 1ef2dd45f38fa17b7df59d80faf6cf44dff9222e Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Thu, 12 Jun 2014 11:00:22 +0200 Subject: [PATCH] Check for Mnesia node name mismatches Log a proper error message if the node running ejabberd doesn't own the Mnesia database. --- src/ejabberd_app.erl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ejabberd_app.erl b/src/ejabberd_app.erl index 8106b7b0d..6b0a85be8 100644 --- a/src/ejabberd_app.erl +++ b/src/ejabberd_app.erl @@ -107,6 +107,18 @@ loop() -> end. db_init() -> + MyNode = node(), + DbNodes = mnesia:system_info(db_nodes), + case lists:member(MyNode, DbNodes) of + true -> + ok; + false -> + ?CRITICAL_MSG("Node name mismatch: I'm [~s], " + "the database is owned by ~p", [MyNode, DbNodes]), + ?CRITICAL_MSG("Either set ERLANG_NODE in ejabberdctl.cfg " + "or change node name in Mnesia", []), + erlang:error(node_name_mismatch) + end, case mnesia:system_info(extra_db_nodes) of [] -> mnesia:create_schema([node()]);