summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2013-04-05 17:26:01 +0100
committerSimon MacMullen <simon@rabbitmq.com>2013-04-05 17:26:01 +0100
commite2c1ff54a9db9c92c3c9e732c21cd2a5ccbccbc5 (patch)
tree552fa5777d684c62e6613c99d06835296b6ce901
parent964f43befe1a48e5256ee1bfb77bc6b7422e4c05 (diff)
downloadrabbitmq-server-bug25514.tar.gz
Only queue up for GC at most two pairs of files at once, since we lock files as soon as they are queued; no point in having them locked for ages as they wait to get GCed.bug25514
-rw-r--r--src/rabbit_msg_store.erl11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/rabbit_msg_store.erl b/src/rabbit_msg_store.erl
index c2d8e06e..112d1ce2 100644
--- a/src/rabbit_msg_store.erl
+++ b/src/rabbit_msg_store.erl
@@ -51,6 +51,9 @@
-define(HANDLE_CACHE_BUFFER_SIZE, 1048576). %% 1MB
+ %% i.e. two pairs, so GC does not go idle when busy
+-define(MAXIMUM_SIMULTANEOUS_GC_FILES, 4).
+
%%----------------------------------------------------------------------------
-record(msstate,
@@ -1731,10 +1734,12 @@ maybe_compact(State = #msstate { sum_valid_data = SumValid,
(SumFileSize - SumValid) / SumFileSize > ?GARBAGE_FRACTION ->
%% TODO: the algorithm here is sub-optimal - it may result in a
%% complete traversal of FileSummaryEts.
- case ets:first(FileSummaryEts) of
- '$end_of_table' ->
+ First = ets:first(FileSummaryEts),
+ case First =:= '$end_of_table' orelse
+ orddict:size(Pending) >= ?MAXIMUM_SIMULTANEOUS_GC_FILES of
+ true ->
State;
- First ->
+ false ->
case find_files_to_combine(FileSummaryEts, FileSizeLimit,
ets:lookup(FileSummaryEts, First)) of
not_found ->