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
commitff3430c509458ed48568f3d7b19607531d6dca63 (patch)
treea25ee454626e3b76c6facaa0f0f02648f74cd517
parentb558d28a63ba9c84e4d33dcf4775692b894f3ff0 (diff)
downloadrabbitmq-server-git-ff3430c509458ed48568f3d7b19607531d6dca63.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 775a16648a..2df8304683 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)