aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mnesia/src/mnesia_controller.erl
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2014-08-27 09:00:14 +0200
committerDan Gudmundsson <[email protected]>2014-08-28 09:18:45 +0200
commit6ba2b5402c3dea5b765034436ae9e6b3ca4e2ce5 (patch)
tree2d3c0112d3293fa0584d0ab24ecdbf0a7e22d962 /lib/mnesia/src/mnesia_controller.erl
parent56715334380680c1466d2a9165ea2f7affc93a78 (diff)
downloadotp-6ba2b5402c3dea5b765034436ae9e6b3ca4e2ce5.tar.gz
otp-6ba2b5402c3dea5b765034436ae9e6b3ca4e2ce5.tar.bz2
otp-6ba2b5402c3dea5b765034436ae9e6b3ca4e2ce5.zip
Avoid timing issue in schema transaction when node is stopping
By doing an abort, the create_table can be restarted if a node go down during the transaction. {badarg, [{erlang,link,[undefined],[]}, {mnesia_controller, wait_for_schema_commit_lock,0, [{file,"mnesia_controller.erl"}, {line,303}]}, {mnesia_schema,prepare_commit,3, [{file,"mnesia_schema.erl"}, {line,1838}]}, {mnesia_tm,commit_participant,6, [{file,"mnesia_tm.erl"}, {line,1669}]}]}}},
Diffstat (limited to 'lib/mnesia/src/mnesia_controller.erl')
-rw-r--r--lib/mnesia/src/mnesia_controller.erl15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/mnesia/src/mnesia_controller.erl b/lib/mnesia/src/mnesia_controller.erl
index fe2fd67d71..5a9bae54da 100644
--- a/lib/mnesia/src/mnesia_controller.erl
+++ b/lib/mnesia/src/mnesia_controller.erl
@@ -300,8 +300,13 @@ mnesia_down(Node) ->
end.
wait_for_schema_commit_lock() ->
- link(whereis(?SERVER_NAME)),
- unsafe_call(wait_for_schema_commit_lock).
+ try
+ Pid = whereis(?SERVER_NAME),
+ link(Pid), %% Keep the link until release_schema_commit_lock
+ gen_server:call(Pid, wait_for_schema_commit_lock, infinity)
+ catch _:_ ->
+ mnesia:abort({node_not_running, node()})
+ end.
block_controller() ->
call(block_controller).
@@ -557,12 +562,6 @@ cast(Msg) ->
abcast(Nodes, Msg) ->
gen_server:abcast(Nodes, ?SERVER_NAME, Msg).
-unsafe_call(Msg) ->
- case whereis(?SERVER_NAME) of
- undefined -> {error, {node_not_running, node()}};
- Pid -> gen_server:call(Pid, Msg, infinity)
- end.
-
call(Msg) ->
case whereis(?SERVER_NAME) of
undefined ->