diff options
author | Ahmed Omar <spawn.think@gmail.com> | 2013-05-02 10:19:12 +0200 |
---|---|---|
committer | Ahmed Omar <spawn.think@gmail.com> | 2013-05-02 10:19:28 +0200 |
commit | 1a5f96ce02e8228c09e214a0736e2ffa0a8091ee (patch) | |
tree | 694112b0a390a36b59567036f20a34ddf405f45c | |
parent | d93043ca0839e659abada62b0c6cf4d441808acf (diff) | |
download | erlang-1a5f96ce02e8228c09e214a0736e2ffa0a8091ee.tar.gz |
Fix crash in mnesia_controller due to a function_clause exception from is_tab_blocked/1
If mnesia_controller:block_table/1 is called twice for same table,
the new stored value of {Tab, where_to_commit} will be {blocked, {blocked,List}}.
This will result in an exception when calling is_tab_blocked/1.
mnesia_conttoller:block_table/1 should check if the table is already blocked.
-rw-r--r-- | lib/mnesia/src/mnesia_controller.erl | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/mnesia/src/mnesia_controller.erl b/lib/mnesia/src/mnesia_controller.erl index 78f7bfa325..b1f8886e7f 100644 --- a/lib/mnesia/src/mnesia_controller.erl +++ b/lib/mnesia/src/mnesia_controller.erl @@ -1676,9 +1676,13 @@ add_active_replica(Tab, Node, Cs = #cstruct{}) -> block_table(Tab) -> Var = {Tab, where_to_commit}, - Old = val(Var), - New = {blocked, Old}, - set(Var, New). % where_to_commit + case is_tab_blocked(val(Var)) of + {false, Old}-> + New = {blocked, Old}, + set(Var, New); % where_to_commit + {true, _Old}-> % already blocked + ignore + end. unblock_table(Tab) -> call({unblock_table, Tab}). |