summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlvaro Videla <videlalvaro@gmail.com>2015-10-13 20:50:31 +0200
committerAlvaro Videla <videlalvaro@gmail.com>2015-10-13 20:50:31 +0200
commit24eff3e741bc2b5a5f8f75e07ae604044381cda9 (patch)
tree6e5d862e868386d225639b439889aee79f0f3d07 /src
parent4f936195ddda26337bc858c18163b1593468c1b6 (diff)
downloadrabbitmq-server-git-24eff3e741bc2b5a5f8f75e07ae604044381cda9.tar.gz
makes sure convert_to_lazy terminates
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_variable_queue.erl33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/rabbit_variable_queue.erl b/src/rabbit_variable_queue.erl
index 6fdb53ba45..0bc288173f 100644
--- a/src/rabbit_variable_queue.erl
+++ b/src/rabbit_variable_queue.erl
@@ -920,21 +920,26 @@ set_queue_mode(default, State) ->
set_queue_mode(_, State) ->
State.
-convert_to_lazy(State = #vqstate { ram_msg_count = 0}) ->
- State;
convert_to_lazy(State) ->
- State1 = set_ram_duration_target(0, State),
- %% When pushing messages to disk, we might have been blocked by
- %% the msg_store, so we need to see if we have to wait for more
- %% credit, and the keep paging messages.
- %%
- %% The amqqueue_process could have taken care of this, but between
- %% the time it receives the bump_credit msg and calls BQ:resume to
- %% keep paging messages to disk, some other request may arrive to
- %% the BQ which at this moment is not in a proper state for a lazy
- %% BQ (unless all messages have been paged to disk already).
- wait_for_msg_store_credit(),
- convert_to_lazy(State1).
+ State1 = #vqstate { ram_msg_count = RMC, q3 = Q3 } =
+ set_ram_duration_target(0, State),
+ case RMC =:= ?QUEUE:len(Q3) of
+ true ->
+ State1;
+ false ->
+ %% When pushing messages to disk, we might have been
+ %% blocked by the msg_store, so we need to see if we have
+ %% to wait for more credit, and the keep paging messages.
+ %%
+ %% The amqqueue_process could have taken care of this, but
+ %% between the time it receives the bump_credit msg and
+ %% calls BQ:resume to keep paging messages to disk, some
+ %% other request may arrive to the BQ which at this moment
+ %% is not in a proper state for a lazy BQ (unless all
+ %% messages have been paged to disk already).
+ wait_for_msg_store_credit(),
+ convert_to_lazy(State1)
+ end.
wait_for_msg_store_credit() ->
case credit_flow:blocked() of