aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mnesia/src/mnesia_lib.erl
diff options
context:
space:
mode:
authorUlf Wiger <[email protected]>2010-05-09 12:15:56 +0200
committerUlf Wiger <[email protected]>2010-05-09 12:15:56 +0200
commit82c090488eb76d16e8b828bb8f050afd0949e4c4 (patch)
tree6332210528c3bc10ad60fb526f415c1b7055e8a5 /lib/mnesia/src/mnesia_lib.erl
parenta21a9dac550bcb976fa074d7005499a4d6b55791 (diff)
downloadotp-82c090488eb76d16e8b828bb8f050afd0949e4c4.tar.gz
otp-82c090488eb76d16e8b828bb8f050afd0949e4c4.tar.bz2
otp-82c090488eb76d16e8b828bb8f050afd0949e4c4.zip
Enable continuous monitoring of mnesia overload status
Mnesia currently issues an event whenever it detects an overload condition. It recognizes two different types of overload: - whenever the message queue of mnesia_tm process grows large - when a log dump interval triggers before the previous dump is done These events could be used to trigger a load regulation mechanism to reduce the load until the condition seizes. The missing piece is that there is no facility to ask mnesia whether the overload condition still exists. This patch implements a couple of functions in mnesia_lib that can be used to sample the overload status. It has been tested in a load regulator component being developed by Erlang Solutions. No mnesia test suites have been run, since they are not available. No documentation has been updated. The functions in mnesia_lib are at any rate undocumented (as are all other functions in that module). A decision would have to be made about whether to provide a documented API on top of these functions. The internal state record of mnesia_recover has been modified. For this reason, a code change hook has been provided.
Diffstat (limited to 'lib/mnesia/src/mnesia_lib.erl')
-rw-r--r--lib/mnesia/src/mnesia_lib.erl30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/mnesia/src/mnesia_lib.erl b/lib/mnesia/src/mnesia_lib.erl
index dba808e66e..168e225289 100644
--- a/lib/mnesia/src/mnesia_lib.erl
+++ b/lib/mnesia/src/mnesia_lib.erl
@@ -113,6 +113,9 @@
mkcore/1,
not_active_here/1,
other_val/2,
+ overload_read/0,
+ overload_read/1,
+ overload_set/2,
pad_name/3,
random_time/2,
read_counter/1,
@@ -551,6 +554,33 @@ cs_to_nodes(Cs) ->
Cs#cstruct.disc_only_copies ++
Cs#cstruct.disc_copies ++
Cs#cstruct.ram_copies.
+
+overload_types() ->
+ [mnesia_tm, mnesia_dump_log].
+
+valid_overload_type(T) ->
+ case lists:member(T, overload_types()) of
+ false ->
+ erlang:error(bad_type);
+ true ->
+ true
+ end.
+
+overload_set(Type, Bool) when is_boolean(Bool) ->
+ valid_overload_type(Type),
+ set({overload, Type}, Bool).
+
+overload_read() ->
+ [{T, overload_read(T)} || T <- overload_types()].
+
+overload_read(T) ->
+ case ?catch_val({overload, T}) of
+ {'EXIT',_} ->
+ valid_overload_type(T),
+ false;
+ Flag when is_boolean(Flag) ->
+ Flag
+ end.
dist_coredump() ->
dist_coredump(all_nodes()).