Skip to content

Commit 70a6e64

Browse files
authored
Merge pull request #14341 from rabbitmq/mergify/bp/v4.1.x/pr-14333
Retry stream SAC unregister consumer operation (backport #14333)
2 parents dcbd1e2 + c648716 commit 70a6e64

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

deps/rabbitmq_stream/src/rabbit_stream_reader.erl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4042,9 +4042,10 @@ sac_register_consumer(VH, St, PartitionIndex, Name, Pid, ConnName, SubId) ->
40424042
end).
40434043

40444044
sac_unregister_consumer(VH, St, Name, Pid, SubId) ->
4045-
sac_call(fun() ->
4046-
?SAC_MOD:unregister_consumer(VH, St, Name, Pid, SubId)
4047-
end).
4045+
Call = fun() ->
4046+
?SAC_MOD:unregister_consumer(VH, St, Name, Pid, SubId)
4047+
end,
4048+
sac_call(retryable_sac_call(Call)).
40484049

40494050
sac_call(Call) ->
40504051
case Call() of
@@ -4060,3 +4061,16 @@ sac_call(Call) ->
40604061
R ->
40614062
R
40624063
end.
4064+
4065+
retryable_sac_call(Call) ->
4066+
fun() -> retry_sac_call(Call, 3) end.
4067+
4068+
retry_sac_call(_Call, 0) ->
4069+
{error, coordinator_unavailable};
4070+
retry_sac_call(Call, N) ->
4071+
case Call() of
4072+
{error, coordinator_unavailable} ->
4073+
retry_sac_call(Call, N - 1);
4074+
R ->
4075+
R
4076+
end.

0 commit comments

Comments
 (0)