Return error if SAC has no name

Single active consumer must have a name, which is used as the reference
for storing offsets and as the name of the group the consumer belongs
to in case the stream is a partition of a super stream.

References #3753
This commit is contained in:
Arnaud Cogoluègnes 2022-03-28 14:37:06 +02:00
parent 4cb814dd1c
commit ee79237bf6
No known key found for this signature in database
GPG Key ID: D5C8C4DFAD43AFA8
1 changed files with 16 additions and 2 deletions

View File

@ -1880,9 +1880,10 @@ handle_frame_post_auth(Transport,
Sac = single_active_consumer(Properties),
ConsumerName = consumer_name(Properties),
%% TODO check consumer name is defined when SAC
case {Sac, rabbit_stream_utils:is_sac_ff_enabled()}
case {Sac, rabbit_stream_utils:is_sac_ff_enabled(),
ConsumerName}
of
{true, false} ->
{true, false, _} ->
rabbit_log:warning("Cannot create subcription ~p, stream single active "
"consumer feature flag is not enabled",
[SubscriptionId]),
@ -1895,6 +1896,19 @@ handle_frame_post_auth(Transport,
?PRECONDITION_FAILED,
1),
{Connection, State};
{true, _, undefined} ->
rabbit_log:warning("Cannot create subcription ~p, a single active "
"consumer must have a name",
[SubscriptionId]),
response(Transport,
Connection,
subscribe,
CorrelationId,
?RESPONSE_CODE_PRECONDITION_FAILED),
rabbit_global_counters:increase_protocol_counter(stream,
?PRECONDITION_FAILED,
1),
{Connection, State};
_ ->
Log = case Sac of
true ->