Skip to content

Commit 9994032

Browse files
Merge pull request #3572 from rabbitmq/mergify/bp/v3.9.x/pr-3560
Fix memory leak when using mandatory flag in CQs (backport #3560)
2 parents fb72068 + 347a813 commit 9994032

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

deps/rabbit/src/rabbit_classic_queue.erl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,9 @@ settlement_action(Type, QRef, MsgSeqs, Acc) ->
299299
deliver(Qs0, #delivery{flow = Flow,
300300
msg_seq_no = MsgNo,
301301
message = #basic_message{exchange_name = _Ex},
302-
confirm = _Confirm} = Delivery) ->
302+
confirm = Confirm} = Delivery) ->
303303
%% TODO: record master and slaves for confirm processing
304-
{MPids, SPids, Qs, Actions} = qpids(Qs0, MsgNo),
304+
{MPids, SPids, Qs, Actions} = qpids(Qs0, Confirm, MsgNo),
305305
QPids = MPids ++ SPids,
306306
case Flow of
307307
%% Here we are tracking messages sent by the rabbit_channel
@@ -361,22 +361,22 @@ purge(Q) when ?is_amqqueue(Q) ->
361361
QPid = amqqueue:get_pid(Q),
362362
delegate:invoke(QPid, {gen_server2, call, [purge, infinity]}).
363363

364-
qpids(Qs, MsgNo) ->
364+
qpids(Qs, Confirm, MsgNo) ->
365365
lists:foldl(
366366
fun ({Q, S0}, {MPidAcc, SPidAcc, Qs0, Actions0}) ->
367367
QPid = amqqueue:get_pid(Q),
368368
SPids = amqqueue:get_slave_pids(Q),
369369
QRef = amqqueue:get_name(Q),
370370
Actions = [{monitor, QPid, QRef}
371371
| [{monitor, P, QRef} || P <- SPids]] ++ Actions0,
372-
%% confirm record only if MsgNo isn't undefined
372+
%% confirm record only if necessary
373373
S = case S0 of
374374
#?STATE{unconfirmed = U0} ->
375375
Rec = [QPid | SPids],
376-
U = case MsgNo of
377-
undefined ->
376+
U = case Confirm of
377+
false ->
378378
U0;
379-
_ ->
379+
true ->
380380
U0#{MsgNo => #msg_status{pending = Rec}}
381381
end,
382382
S0#?STATE{pid = QPid,

release-notes/3.9.8.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ Contributors are encouraged to update them together with their changes. This hel
2323
* When the mandatory flag was used when publishing to classic queues,
2424
but publisher confirms were not, channels memory usage would grow indefinitely.
2525

26-
GitHub issue: [#3560](https://github.com/rabbitmq/rabbitmq-server/issues/3560)
26+
GitHub issue: [#3560](https://github.com/rabbitmq/rabbitmq-server/issues/3560)
2727

2828
* `rabbitmq-diagnostics memory_breakdown` failed to read memory of connection
2929
reader, writer and channel processes.
3030

31-
GitHub issue: [#3570](https://github.com/rabbitmq/rabbitmq-server/issues/3570)
31+
GitHub issue: [#3570](https://github.com/rabbitmq/rabbitmq-server/issues/3570)
3232

3333

3434
## Dependency Upgrades

0 commit comments

Comments
 (0)