aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Romain <christophe.romain@process-one.net>2017-01-20 09:26:13 +0100
committerChristophe Romain <christophe.romain@process-one.net>2017-01-20 09:26:13 +0100
commit4f5d54f0622e0869f096d0a0324f4fce5264a8f4 (patch)
tree3b511293c722cb59060c5f8a70429b1a528786e7
parentRestore muc_invite_hook (#1467) (diff)
Try db migration only when mnesia is configured (#1458)
-rw-r--r--src/mod_pubsub.erl21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl
index 81ad028a3..108c0b593 100644
--- a/src/mod_pubsub.erl
+++ b/src/mod_pubsub.erl
@@ -262,7 +262,10 @@ init([ServerHost, Opts]) ->
fun(A) when is_integer(A) andalso A >= 0 -> A end, ?MAXITEMS),
MaxSubsNode = gen_mod:get_opt(max_subscriptions_node, Opts,
fun(A) when is_integer(A) andalso A >= 0 -> A end, undefined),
- [pubsub_index:init(Host, ServerHost, Opts) || gen_mod:db_type(ServerHost, ?MODULE)==mnesia],
+ case gen_mod:db_type(ServerHost, ?MODULE) of
+ mnesia -> init_mnesia(Host, ServerHost, Opts);
+ _ -> ok
+ end,
{Plugins, NodeTree, PepMapping} = init_plugins(Host, ServerHost, Opts),
DefaultModule = plugin(Host, hd(Plugins)),
BaseOptions = DefaultModule:options(),
@@ -336,10 +339,6 @@ init([ServerHost, Opts]) ->
false ->
ok
end,
- pubsub_migrate:update_node_database(Host, ServerHost),
- pubsub_migrate:update_state_database(Host, ServerHost),
- pubsub_migrate:update_item_database(Host, ServerHost),
- pubsub_migrate:update_lastitem_database(Host, ServerHost),
{_, State} = init_send_loop(ServerHost),
{ok, State}.
@@ -382,6 +381,18 @@ depends(ServerHost, Opts) ->
end
end, Plugins).
+init_mnesia(Host, ServerHost, Opts) ->
+ pubsub_index:init(Host, ServerHost, Opts),
+ spawn(fun() ->
+ %% maybe upgrade db. this can take time when upgrading existing
+ %% data from ejabberd 2.1.x, so we don't want this to block
+ %% calling gen_server:start
+ pubsub_migrate:update_node_database(Host, ServerHost),
+ pubsub_migrate:update_state_database(Host, ServerHost),
+ pubsub_migrate:update_item_database(Host, ServerHost),
+ pubsub_migrate:update_lastitem_database(Host, ServerHost)
+ end).
+
%% @doc Call the init/1 function for each plugin declared in the config file.
%% The default plugin module is implicit.
%% <p>The Erlang code for the plugin is located in a module called