aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mnesia/src/mnesia_locker.erl
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2016-02-09 15:11:30 +0100
committerDan Gudmundsson <[email protected]>2016-02-09 15:11:30 +0100
commitc1f4d4a6d5c189f7cd4b3b073fb47f8dfb8d3fff (patch)
tree44dfb74c074f3719097673770f9e877a1f52899b /lib/mnesia/src/mnesia_locker.erl
parent6233c5db89867fae35f69bd7b8ef94b32cec605d (diff)
downloadotp-c1f4d4a6d5c189f7cd4b3b073fb47f8dfb8d3fff.tar.gz
otp-c1f4d4a6d5c189f7cd4b3b073fb47f8dfb8d3fff.tar.bz2
otp-c1f4d4a6d5c189f7cd4b3b073fb47f8dfb8d3fff.zip
mnesia: let loader check if tablelock is needed
move_table_copy needs the lock that was set previously in del_table_copy. This doesn't work on old nodes, so bump protocol version and check it. Remove old protocol conversion code, which have been around since OTP-R15. Checking if lock is needed requires rpc communication via mnesia_gvar ets table to be backwards compatible.
Diffstat (limited to 'lib/mnesia/src/mnesia_locker.erl')
-rw-r--r--lib/mnesia/src/mnesia_locker.erl20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/mnesia/src/mnesia_locker.erl b/lib/mnesia/src/mnesia_locker.erl
index 89feeba2c3..5766f22e92 100644
--- a/lib/mnesia/src/mnesia_locker.erl
+++ b/lib/mnesia/src/mnesia_locker.erl
@@ -22,7 +22,7 @@
-module(mnesia_locker).
-export([
- get_held_locks/0,
+ get_held_locks/0, get_held_locks/1,
get_lock_queue/0,
global_lock/5,
ixrlock/5,
@@ -236,6 +236,11 @@ loop(State) ->
From ! {Ref, ok},
loop(State);
+ {From, {is_locked, Oid}} ->
+ Held = ?ets_lookup(mnesia_held_locks, Oid),
+ reply(From, Held),
+ loop(State);
+
{'EXIT', Pid, _} when Pid == State#state.supervisor ->
do_stop();
@@ -1151,6 +1156,19 @@ get_held_locks() ->
Locks = receive {mnesia_held_locks, Ls} -> Ls after 5000 -> [] end,
rewrite_locks(Locks, []).
+%% Mnesia internal usage only
+get_held_locks(Tab) when is_atom(Tab) ->
+ Oid = {Tab, ?ALL},
+ ?MODULE ! {self(), {is_locked, Oid}},
+ receive
+ {?MODULE, _Node, Locks} ->
+ case Locks of
+ [] -> [];
+ [{Oid, _Prev, What}] -> What
+ end
+ end.
+
+
rewrite_locks([{Oid, _, Ls}|Locks], Acc0) ->
Acc = rewrite_locks(Ls, Oid, Acc0),
rewrite_locks(Locks, Acc);