Skip to content

Commit

Permalink
Classic queue: discard rejected msg even when publisher-confirm disabled
Browse files Browse the repository at this point in the history
Otherwise the message is never removed from the state of mirrored queue
slaves.

Fixes rabbitmq#9905
  • Loading branch information
gomoripeti committed Nov 10, 2023
1 parent 09a95a5 commit 7b7ff7e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions deps/rabbit/src/rabbit_amqqueue_process.erl
Original file line number Diff line number Diff line change
Expand Up @@ -816,16 +816,28 @@ 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),

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;
Expand Down

0 comments on commit 7b7ff7e

Please sign in to comment.