Skip to content

Commit 83d2f72

Browse files
gomoripetimergify[bot]
authored andcommitted
Handle missing delivery marker in CQ v1 index
This can happen when a classic queue has messages published on a pre-3.10 RabbitMQ version, but still present after an upgrade to 3.10+. Fixes #7904 (cherry picked from commit be2e546) (cherry picked from commit 690b319) (cherry picked from commit ec396d3)
1 parent dc9ecc9 commit 83d2f72

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

deps/rabbit/src/rabbit_queue_index.erl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,10 @@ action_to_entry(RelSeq, Action, JEntries) ->
966966
({no_pub, del, no_ack}) when Action == ack ->
967967
{set, {no_pub, del, ack}};
968968
({?PUB, del, no_ack}) when Action == ack ->
969+
{reset, none};
970+
%% Special case, missing del
971+
%% See journal_minus_segment1/2
972+
({?PUB, no_del, no_ack}) when Action == ack ->
969973
{reset, none}
970974
end.
971975

@@ -1356,6 +1360,11 @@ segment_plus_journal1({?PUB = Pub, no_del, no_ack}, {no_pub, del, no_ack}) ->
13561360
segment_plus_journal1({?PUB, no_del, no_ack}, {no_pub, del, ack}) ->
13571361
{undefined, -1};
13581362
segment_plus_journal1({?PUB, del, no_ack}, {no_pub, no_del, ack}) ->
1363+
{undefined, -1};
1364+
1365+
%% Special case, missing del
1366+
%% See journal_minus_segment1/2
1367+
segment_plus_journal1({?PUB, no_del, no_ack}, {no_pub, no_del, ack}) ->
13591368
{undefined, -1}.
13601369

13611370
%% Remove from the journal entries for a segment, items that are
@@ -1427,6 +1436,16 @@ journal_minus_segment1({no_pub, no_del, ack}, {?PUB, del, no_ack}) ->
14271436
journal_minus_segment1({no_pub, no_del, ack}, {?PUB, del, ack}) ->
14281437
{undefined, -1};
14291438

1439+
%% Just ack in journal, missing del
1440+
%% Since 3.10 message delivery is tracked per-queue, not per-message,
1441+
%% but to keep queue index v1 format messages are always marked as
1442+
%% delivered on publish. But for a message that was published before
1443+
%% 3.10 this is not the case and the delivery marker can be missing.
1444+
%% As a workaround we add the del marker because if a message is acked
1445+
%% it must have been delivered as well.
1446+
journal_minus_segment1({no_pub, no_del, ack}, {?PUB, no_del, no_ack}) ->
1447+
{{no_pub, del, ack}, 0};
1448+
14301449
%% Deliver and ack in journal
14311450
journal_minus_segment1({no_pub, del, ack}, {?PUB, no_del, no_ack}) ->
14321451
{keep, 0};

0 commit comments

Comments
 (0)