summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Watson <tim@rabbitmq.com>2013-06-05 17:16:56 +0100
committerTim Watson <tim@rabbitmq.com>2013-06-05 17:16:56 +0100
commitdc6796c95a339685a1b68a5f26dd2882f9f5bc57 (patch)
tree8321c215d2874e6987a5a8c605779d3b443c40b0
parent88e20d03a2c80aeee37df6f50bc610bd2a0ff999 (diff)
parenta41af647791ac3a3de76364c7e352863c106f50e (diff)
downloadrabbitmq-server-dc6796c95a339685a1b68a5f26dd2882f9f5bc57.tar.gz
merge stable into default
-rw-r--r--src/rabbit_tests.erl15
-rw-r--r--src/rabbit_variable_queue.erl7
2 files changed, 17 insertions, 5 deletions
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl
index f32fe740..21c54f3e 100644
--- a/src/rabbit_tests.erl
+++ b/src/rabbit_tests.erl
@@ -2393,6 +2393,7 @@ test_variable_queue() ->
fun test_variable_queue_ack_limiting/1,
fun test_variable_queue_purge/1,
fun test_variable_queue_requeue/1,
+ fun test_variable_queue_requeue_ram_beta/1,
fun test_variable_queue_fold/1]],
passed.
@@ -2491,6 +2492,20 @@ test_variable_queue_requeue(VQ0) ->
{empty, VQ3} = rabbit_variable_queue:fetch(true, VQ2),
VQ3.
+%% requeue from ram_pending_ack into q3, move to delta and then empty queue
+test_variable_queue_requeue_ram_beta(VQ0) ->
+ Count = rabbit_queue_index:next_segment_boundary(0)*2 + 2,
+ VQ1 = rabbit_tests:variable_queue_publish(false, Count, VQ0),
+ {VQ2, AcksR} = variable_queue_fetch(Count, false, false, Count, VQ1),
+ {Back, Front} = lists:split(Count div 2, AcksR),
+ {_, VQ3} = rabbit_variable_queue:requeue(erlang:tl(Back), VQ2),
+ VQ4 = rabbit_variable_queue:set_ram_duration_target(0, VQ3),
+ {_, VQ5} = rabbit_variable_queue:requeue([erlang:hd(Back)], VQ4),
+ VQ6 = requeue_one_by_one(Front, VQ5),
+ {VQ7, AcksAll} = variable_queue_fetch(Count, false, true, Count, VQ6),
+ {_, VQ8} = rabbit_variable_queue:ack(AcksAll, VQ7),
+ VQ8.
+
test_variable_queue_purge(VQ0) ->
LenDepth = fun (VQ) ->
{rabbit_variable_queue:len(VQ),
diff --git a/src/rabbit_variable_queue.erl b/src/rabbit_variable_queue.erl
index f7c6c729..5b39c2c6 100644
--- a/src/rabbit_variable_queue.erl
+++ b/src/rabbit_variable_queue.erl
@@ -1363,11 +1363,8 @@ publish_alpha(MsgStatus, State) ->
{MsgStatus, inc_ram_msg_count(State)}.
publish_beta(MsgStatus, State) ->
- {#msg_status { msg = Msg} = MsgStatus1,
- #vqstate { ram_msg_count = RamMsgCount } = State1} =
- maybe_write_to_disk(true, false, MsgStatus, State),
- {MsgStatus1, State1 #vqstate {
- ram_msg_count = RamMsgCount + one_if(Msg =/= undefined) }}.
+ {MsgStatus1, State1} = maybe_write_to_disk(true, false, MsgStatus, State),
+ {m(trim_msg_status(MsgStatus1)), State1}.
%% Rebuild queue, inserting sequence ids to maintain ordering
queue_merge(SeqIds, Q, MsgIds, Limit, PubFun, State) ->