Skip to content

Commit 03b2db6

Browse files
committed
Fix queue storage version returned by priority queues
Fixes #9370
1 parent d50e318 commit 03b2db6

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
@@ -652,7 +652,13 @@ priority_on_acktags(P, AckTags) ->
652652
combine_status(P, New, nothing) ->
653653
[{priority_lengths, [{P, proplists:get_value(len, New)}]} | New];
654654
combine_status(P, New, Old) ->
655-
Combined = [{K, cse(V, proplists:get_value(K, Old))} || {K, V} <- New],
655+
Combined = [case K of
656+
version ->
657+
{K, proplists:get_value(version, Old)};
658+
_ ->
659+
{K, cse(V, proplists:get_value(K, Old))}
660+
end
661+
|| {K, V} <- New],
656662
Lens = [{P, proplists:get_value(len, New)} |
657663
proplists:get_value(priority_lengths, Old)],
658664
[{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
@@ -28,6 +28,7 @@ groups() ->
2828
{overflow_reject_publish_dlx, [], [reject]},
2929
dropwhile_fetchwhile,
3030
info_head_message_timestamp,
31+
info_backing_queue_version,
3132
unknown_info_key,
3233
matching,
3334
purge,
@@ -393,6 +394,27 @@ info_head_message_timestamp1(_Config) ->
393394
PQ:delete_and_terminate(a_whim, BQS6),
394395
passed.
395396

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

0 commit comments

Comments
 (0)