summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-02-24 12:55:53 +0000
committerSimon MacMullen <simon@rabbitmq.com>2014-02-24 12:55:53 +0000
commit3412999ece989f7a7020e244361b75e2dc7262b9 (patch)
tree891590a880b8d88c6569bd3a75f68afa7523fee6 /src
parente290c32a76046e14b4e629391f8743ea030d1eab (diff)
parent2ce81391ce7e74a9d316d26fd5ef72c8ad3b3891 (diff)
downloadrabbitmq-server-git-3412999ece989f7a7020e244361b75e2dc7262b9.tar.gz
Merge bug25994
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_amqqueue_process.erl13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index a1997376c1..ec1a977db7 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -859,12 +859,21 @@ prioritise_cast(Msg, _Len, State) ->
{set_ram_duration_target, _Duration} -> 8;
{set_maximum_since_use, _Age} -> 8;
{run_backing_queue, _Mod, _Fun} -> 6;
- {ack, _AckTags, _ChPid} -> consumer_bias(State);
+ {ack, _AckTags, _ChPid} -> 3; %% [1]
+ {resume, _ChPid} -> 2;
{notify_sent, _ChPid, _Credit} -> consumer_bias(State);
- {resume, _ChPid} -> consumer_bias(State);
_ -> 0
end.
+%% [1] It should be safe to always prioritise ack / resume since they
+%% will be rate limited by how fast consumers receive messages -
+%% i.e. by notify_sent. We prioritise ack and resume to discourage
+%% starvation caused by prioritising notify_sent. We don't vary their
+%% prioritiy since acks should stay in order (some parts of the queue
+%% stack are optimised for that) and to make things easier to reason
+%% about. Finally, we prioritise ack over resume since it should
+%% always reduce memory use.
+
consumer_bias(#q{backing_queue = BQ, backing_queue_state = BQS}) ->
case BQ:msg_rates(BQS) of
{0.0, _} -> 0;