Skip to content

Commit 7be502a

Browse files
gomoripetimergify[bot]
authored andcommitted
Fix queue storage version returned by priority queues
Fixes #9370 (cherry picked from commit 03b2db6)
1 parent 678b098 commit 7be502a

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

deps/rabbit/src/rabbit_priority_queue.erl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,13 @@ priority_on_acktags(P, AckTags) ->
656656
combine_status(P, New, nothing) ->
657657
[{priority_lengths, [{P, proplists:get_value(len, New)}]} | New];
658658
combine_status(P, New, Old) ->
659-
Combined = [{K, cse(V, proplists:get_value(K, Old))} || {K, V} <- New],
659+
Combined = [case K of
660+
version ->
661+
{K, proplists:get_value(version, Old)};
662+
_ ->
663+
{K, cse(V, proplists:get_value(K, Old))}
664+
end
665+
|| {K, V} <- New],
660666
Lens = [{P, proplists:get_value(len, New)} |
661667
proplists:get_value(priority_lengths, Old)],
662668
[{priority_lengths, Lens} | Combined].

deps/rabbit/test/priority_queue_SUITE.erl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ groups() ->
2727
{overflow_reject_publish_dlx, [], [reject]},
2828
dropwhile_fetchwhile,
2929
info_head_message_timestamp,
30+
info_backing_queue_version,
3031
unknown_info_key,
3132
matching,
3233
purge,
@@ -398,6 +399,27 @@ info_head_message_timestamp1(_Config) ->
398399
PQ:delete_and_terminate(a_whim, BQS6),
399400
passed.
400401

402+
info_backing_queue_version(Config) ->
403+
{Conn, Ch} = rabbit_ct_client_helpers:open_connection_and_channel(Config, 0),
404+
Q1 = <<"info-priority-queue-v1">>,
405+
Q2 = <<"info-priority-queue-v2">>,
406+
declare(Ch, Q1, [{<<"x-max-priority">>, byte, 3},
407+
{<<"x-queue-version">>, byte, 1}]),
408+
declare(Ch, Q2, [{<<"x-max-priority">>, byte, 3},
409+
{<<"x-queue-version">>, byte, 2}]),
410+
try
411+
{ok, [{backing_queue_status, BQS1}]} = info(Config, Q1, [backing_queue_status]),
412+
1 = proplists:get_value(version, BQS1),
413+
{ok, [{backing_queue_status, BQS2}]} = info(Config, Q2, [backing_queue_status]),
414+
2 = proplists:get_value(version, BQS2)
415+
after
416+
delete(Ch, Q1),
417+
delete(Ch, Q2),
418+
rabbit_ct_client_helpers:close_channel(Ch),
419+
rabbit_ct_client_helpers:close_connection(Conn),
420+
passed
421+
end.
422+
401423
unknown_info_key(Config) ->
402424
{Conn, Ch} = rabbit_ct_client_helpers:open_connection_and_channel(Config, 0),
403425
Q = <<"info-priority-queue">>,

0 commit comments

Comments
 (0)