summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 ->