From b534e0dae1530cecd2c92fd18a1b54374ec365a8 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 920584ca8ee2..222ec73f52e8 100644 --- a/deps/rabbit/src/rabbit_amqqueue_process.erl +++ b/deps/rabbit/src/rabbit_amqqueue_process.erl @@ -815,15 +815,27 @@ send_reject_publish(#delivery{confirm = true, backing_queue = BQ, backing_queue_state = BQS, msg_id_to_channel = MTC}) -> + %% Drop publish and nack to publisher ok = rabbit_classic_queue:send_rejection(SenderPid, amqqueue:get_name(Q), MsgSeqNo), 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;