diff options
| author | Matthew Sackman <matthew@lshift.net> | 2009-11-17 14:20:57 +0000 |
|---|---|---|
| committer | Matthew Sackman <matthew@lshift.net> | 2009-11-17 14:20:57 +0000 |
| commit | 7acd4c2d736820df513b8a50c584e338d80244ac (patch) | |
| tree | 06ed2dadcee9306c62184954a427431f5e9d5e83 | |
| parent | 81924a0fd9a04d42e76bfceb78b860bacbe3778b (diff) | |
| download | rabbitmq-server-git-7acd4c2d736820df513b8a50c584e338d80244ac.tar.gz | |
If a queue reports 0 duration, then the MM may well calculate that the desired avg duration should be 0. The queue will then be told this on its next report. This is potentially disasterous because for a fast moving queue, setting the duration to 0 will force allmsgs via the disk, which will destroy performance. However, it is not sufficient to just tell all queues reporting 0, infinity, because doing so would result in queues which have been pushed out to disk, suddenly coming all the way back in. Thus if a queue reports a duration of < 1, and the last value we told it was infinity, then we tell it infinity again. Thus fast moving queues are not restricted, and queues which have been told real numbers, and slowly squeezed out to disk stay squeezed out.
| -rw-r--r-- | src/rabbit_memory_monitor.erl | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/rabbit_memory_monitor.erl b/src/rabbit_memory_monitor.erl index be15ecbbe1..ec08d475f0 100644 --- a/src/rabbit_memory_monitor.erl +++ b/src/rabbit_memory_monitor.erl @@ -153,14 +153,19 @@ handle_call({report_queue_duration, Pid, QueueDuration}, From, queue_duration_count = Count, queue_durations = Durations, desired_duration = SendDuration}) -> - gen_server2:reply(From, SendDuration), + [{_Pid, PrevQueueDuration, PrevSendDuration}] = ets:lookup(Durations, Pid), + SendDuration1 = + case QueueDuration < 1 andalso PrevSendDuration == infinity of + true -> infinity; + false -> SendDuration + end, + gen_server2:reply(From, SendDuration1), QueueDuration1 = case QueueDuration > ?MAX_QUEUE_DURATION of true -> infinity; false -> QueueDuration end, - [{_Pid, PrevQueueDuration, _PrevSendDuration}] = ets:lookup(Durations, Pid), {Sum1, Count1} = case {PrevQueueDuration, QueueDuration1} of {infinity, infinity} -> {Sum, Count}; @@ -168,7 +173,7 @@ handle_call({report_queue_duration, Pid, QueueDuration}, From, {_, infinity} -> {Sum - PrevQueueDuration, Count - 1}; {_, _} -> {Sum - PrevQueueDuration + QueueDuration1, Count} end, - true = ets:insert(Durations, {Pid, QueueDuration1, SendDuration}), + true = ets:insert(Durations, {Pid, QueueDuration1, SendDuration1}), {noreply, State#state{queue_duration_sum = Sum1, queue_duration_count = Count1}}; |
