Skip to content

Commit

Permalink
Fix queue storage version returned by priority queues
Browse files Browse the repository at this point in the history
  • Loading branch information
gomoripeti committed Sep 12, 2023
1 parent d50e318 commit 03b2db6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
8 changes: 7 additions & 1 deletion deps/rabbit/src/rabbit_priority_queue.erl
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,13 @@ priority_on_acktags(P, AckTags) ->
combine_status(P, New, nothing) ->
[{priority_lengths, [{P, proplists:get_value(len, New)}]} | New];
combine_status(P, New, Old) ->
Combined = [{K, cse(V, proplists:get_value(K, Old))} || {K, V} <- New],
Combined = [case K of
version ->
{K, proplists:get_value(version, Old)};
_ ->
{K, cse(V, proplists:get_value(K, Old))}
end
|| {K, V} <- New],
Lens = [{P, proplists:get_value(len, New)} |
proplists:get_value(priority_lengths, Old)],
[{priority_lengths, Lens} | Combined].
Expand Down
22 changes: 22 additions & 0 deletions deps/rabbit/test/priority_queue_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ groups() ->
{overflow_reject_publish_dlx, [], [reject]},
dropwhile_fetchwhile,
info_head_message_timestamp,
info_backing_queue_version,
unknown_info_key,
matching,
purge,
Expand Down Expand Up @@ -393,6 +394,27 @@ info_head_message_timestamp1(_Config) ->
PQ:delete_and_terminate(a_whim, BQS6),
passed.

info_backing_queue_version(Config) ->
{Conn, Ch} = rabbit_ct_client_helpers:open_connection_and_channel(Config, 0),
Q1 = <<"info-priority-queue-v1">>,
Q2 = <<"info-priority-queue-v2">>,
declare(Ch, Q1, [{<<"x-max-priority">>, byte, 3},
{<<"x-queue-version">>, byte, 1}]),
declare(Ch, Q2, [{<<"x-max-priority">>, byte, 3},
{<<"x-queue-version">>, byte, 2}]),
try
{ok, [{backing_queue_status, BQS1}]} = info(Config, Q1, [backing_queue_status]),
1 = proplists:get_value(version, BQS1),
{ok, [{backing_queue_status, BQS2}]} = info(Config, Q2, [backing_queue_status]),
2 = proplists:get_value(version, BQS2)
after
delete(Ch, Q1),
delete(Ch, Q2),
rabbit_ct_client_helpers:close_channel(Ch),
rabbit_ct_client_helpers:close_connection(Conn),
passed
end.

unknown_info_key(Config) ->
{Conn, Ch} = rabbit_ct_client_helpers:open_connection_and_channel(Config, 0),
Q = <<"info-priority-queue">>,
Expand Down

0 comments on commit 03b2db6

Please sign in to comment.