summaryrefslogtreecommitdiff
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
commitd053e071af734877847e81445e1b34b36b95cd51 (patch)
tree891590a880b8d88c6569bd3a75f68afa7523fee6
parent18bf717f8cc09864b426fb5c6810086d1a6fece6 (diff)
parentbc88561e6016b6c933d3cc73ff2a66693aedf4cd (diff)
downloadrabbitmq-server-d053e071af734877847e81445e1b34b36b95cd51.tar.gz
Merge bug25994
-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 a1997376..ec1a977d 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;