diff options
author | Erlang/OTP <[email protected]> | 2014-08-29 09:34:37 +0200 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2014-08-29 09:34:37 +0200 |
commit | b1e78c88d2c6259334f565062befd0173c69a899 (patch) | |
tree | 2d3c0112d3293fa0584d0ab24ecdbf0a7e22d962 | |
parent | 56715334380680c1466d2a9165ea2f7affc93a78 (diff) | |
parent | 6ba2b5402c3dea5b765034436ae9e6b3ca4e2ce5 (diff) | |
download | otp-b1e78c88d2c6259334f565062befd0173c69a899.tar.gz otp-b1e78c88d2c6259334f565062befd0173c69a899.tar.bz2 otp-b1e78c88d2c6259334f565062befd0173c69a899.zip |
Merge branch 'dgud/mnesia/create-table-race/OTP-12124' into maint-17
* dgud/mnesia/create-table-race/OTP-12124:
Avoid timing issue in schema transaction when node is stopping
-rw-r--r-- | lib/mnesia/src/mnesia_controller.erl | 15 |
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 -> |