From 7b7ff7e8abcd63afd47adbc5d1092717f1bb66c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20G=C3=B6m=C3=B6ri?= Date: Sat, 11 Nov 2023 00:36:56 +0100 Subject: [PATCH] Classic queue: discard rejected msg even when publisher-confirm disabled Otherwise the message is never removed from the state of mirrored queue slaves. Fixes #9905 --- deps/rabbit/src/rabbit_amqqueue_process.erl | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/deps/rabbit/src/rabbit_amqqueue_process.erl b/deps/rabbit/src/rabbit_amqqueue_process.erl index 7f21b9a06399..347bb373e41a 100644 --- a/deps/rabbit/src/rabbit_amqqueue_process.erl +++ b/deps/rabbit/src/rabbit_amqqueue_process.erl @@ -816,6 +816,7 @@ send_reject_publish(#delivery{confirm = true, backing_queue = BQ, backing_queue_state = BQS, msg_id_to_channel = MTC}) -> + %% Drop publish and nack to publisher MsgId = mc:get_annotation(id, Msg), ok = rabbit_classic_queue:send_rejection(SenderPid, amqqueue:get_name(Q), MsgSeqNo), @@ -823,9 +824,20 @@ send_reject_publish(#delivery{confirm = true, MTC1 = maps:remove(MsgId, MTC), BQS1 = BQ:discard(MsgId, SenderPid, Flow, BQS), State#q{ backing_queue_state = BQS1, msg_id_to_channel = MTC1 }; -send_reject_publish(#delivery{confirm = false}, - _Delivered, State) -> - State. +send_reject_publish(#delivery{confirm = false, + sender = SenderPid, + flow = Flow, + message = Msg}, + _Delivered, + State = #q{q = Q, + backing_queue = BQ, + backing_queue_state = BQS, + msg_id_to_channel = MTC}) -> + %% Only drop publish + MsgId = mc:get_annotation(id, Msg), + MTC1 = maps:remove(MsgId, MTC), + BQS1 = BQ:discard(MsgId, SenderPid, Flow, BQS), + State#q{ backing_queue_state = BQS1, msg_id_to_channel = MTC1 }. will_overflow(_, #q{max_length = undefined, max_bytes = undefined}) -> false;