summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2011-10-11 18:20:29 +0100
committerMatthew Sackman <matthew@rabbitmq.com>2011-10-11 18:20:29 +0100
commit390a906ced1a4febe9b72f1824f2d48dbf437764 (patch)
treea25ee454626e3b76c6facaa0f0f02648f74cd517
parentdf36d772d5a6d6416cec61ade2e85453a2188f37 (diff)
downloadrabbitmq-server-390a906ced1a4febe9b72f1824f2d48dbf437764.tar.gz
Do not use q1+q4 length when calculating permitted ?s - if you do, then as the queue is slowly drained, even whilst target_ram_count may be growing, you can end up writing more out to disk. Instead, use the target_ram_count directly as an indication of ?s. This is preferable as it indicates the permitted ?s which is obviously suitable for use when calculating the permitted ?s.
-rw-r--r--src/rabbit_variable_queue.erl9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/rabbit_variable_queue.erl b/src/rabbit_variable_queue.erl
index 775a1664..2df83046 100644
--- a/src/rabbit_variable_queue.erl
+++ b/src/rabbit_variable_queue.erl
@@ -1482,11 +1482,10 @@ permitted_beta_count(#vqstate { len = 0 }) ->
infinity;
permitted_beta_count(#vqstate { target_ram_count = 0 }) ->
rabbit_queue_index:next_segment_boundary(0);
-permitted_beta_count(#vqstate { len = Len,
- q1 = Q1,
- q4 = Q4 }) ->
- BetaDeltaLen = Len - ?QUEUE:len(Q1) - ?QUEUE:len(Q4),
- lists:max([BetaDeltaLen - ((BetaDeltaLen * BetaDeltaLen) div Len),
+permitted_beta_count(#vqstate { target_ram_count = TargetRamCount,
+ len = Len }) ->
+ BetaDelta = lists:max([0, Len - TargetRamCount]),
+ lists:max([BetaDelta - ((BetaDelta * BetaDelta) div Len),
rabbit_queue_index:next_segment_boundary(0)]).
chunk_size(Current, Permitted)