Skip to content

Commit 1ff2630

Browse files
committed
rabbit_fifo: propery tests for single active consumer
To test send_msg ordering and ensure there never two active consumers at once. [#164691411]
1 parent 7d4fcc6 commit 1ff2630

File tree

2 files changed

+324
-26
lines changed

2 files changed

+324
-26
lines changed

src/rabbit_fifo.erl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,16 @@ apply(Meta, {down, Pid, noconnection},
327327
Credit = increase_credit(C0, maps:size(Checked)),
328328
{St, Effs1} = return_all(State0, Effs,
329329
Cid, C0#consumer{credit = Credit}),
330-
#{Cid := C} = St#?MODULE.consumers,
330+
%% if the consumer was cancelled there is a chance it got
331+
%% removed when returning hence we need to be defensive here
332+
Waiting = case St#?MODULE.consumers of
333+
#{Cid := C} ->
334+
Waiting0 ++ [{Cid, C}];
335+
_ ->
336+
Waiting0
337+
end,
331338
{St#?MODULE{consumers = #{},
332-
waiting_consumers = Waiting0 ++ [{Cid, C}]},
339+
waiting_consumers = Waiting},
333340
Effs1};
334341
_ -> {State0, []}
335342
end,

0 commit comments

Comments
 (0)