aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mnesia/src/mnesia_lib.erl
diff options
context:
space:
mode:
authorUlf Wiger <[email protected]>2010-12-09 18:14:15 +0100
committerHenrik Nord <[email protected]>2011-05-16 11:00:28 +0200
commit38eef7af0f8bc1d2d152cefb8df1e1303ddcac45 (patch)
treed9c59098037eafa221a08efaa085933e8915c127 /lib/mnesia/src/mnesia_lib.erl
parent6d446fc5d08d56174a79ab546d5aa2e79277af06 (diff)
downloadotp-38eef7af0f8bc1d2d152cefb8df1e1303ddcac45.tar.gz
otp-38eef7af0f8bc1d2d152cefb8df1e1303ddcac45.tar.bz2
otp-38eef7af0f8bc1d2d152cefb8df1e1303ddcac45.zip
Write locks now check majority when needed.
Since the table loader also sets (table) write locks, a special lock type, 'load', was needed. Unfortunately, this affects mnesia activity callbacks that redefine the lock operation.
Diffstat (limited to 'lib/mnesia/src/mnesia_lib.erl')
-rw-r--r--lib/mnesia/src/mnesia_lib.erl10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/mnesia/src/mnesia_lib.erl b/lib/mnesia/src/mnesia_lib.erl
index 36bcfe8de9..7e926a6258 100644
--- a/lib/mnesia/src/mnesia_lib.erl
+++ b/lib/mnesia/src/mnesia_lib.erl
@@ -96,6 +96,8 @@
exists/1,
fatal/2,
get_node_number/0,
+ have_majority/2,
+ have_majority/3,
fix_error/1,
important/2,
incr_counter/1,
@@ -660,6 +662,14 @@ proc_info(_) -> false.
get_node_number() ->
{node(), self()}.
+have_majority(Tab, HaveNodes) ->
+ have_majority(Tab, val({Tab, all_nodes}), HaveNodes).
+
+have_majority(_Tab, AllNodes, HaveNodes) ->
+ Missing = AllNodes -- HaveNodes,
+ Present = AllNodes -- Missing,
+ length(Present) > length(Missing).
+
read_log_files() ->
[{F, catch file:read_file(F)} || F <- mnesia_log:log_files()].