Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for sync group response as long as session timeout #380

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,5 @@
* Stop supporting rebar
* Update kafka_protocol dependency to 2.3.6
* Add new brod_group_coordinator:update_topics API
* 3.10.1
* Wait as long as session timeout for sync response
20 changes: 11 additions & 9 deletions src/brod_group_coordinator.erl
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@
%% partitions.</li>
%% </ul></li>
%%
%% <li>`session_timeout_seconds' (optional, default = 10)
%% <li>`session_timeout_seconds' (optional, default = 30)
%%
%% Time in seconds for the group coordinator broker to consider a member
%% 'down' if no heartbeat or any kind of requests received from a broker
%% in the past N seconds.
%% A group member may also consider the coordinator broker 'down' if no
%% heartbeat response response received in the past N seconds.</li>
%%
%% <li>`heartbeat_rate_seconds' (optional, default = 2)
%% <li>`heartbeat_rate_seconds' (optional, default = 5)
%%
%% Time in seconds for the member to 'ping' the group coordinator.
%% OBS: Care should be taken when picking the number, on one hand, we do
Expand Down Expand Up @@ -612,22 +612,24 @@ join_group(#state{ groupId = GroupId
{ok, State}.

-spec sync_group(state()) -> {ok, state()}.
sync_group(#state{ groupId = GroupId
, generationId = GenerationId
, memberId = MemberId
, connection = Connection
, member_pid = MemberPid
, member_module = MemberModule
sync_group(#state{ groupId = GroupId
, generationId = GenerationId
, memberId = MemberId
, connection = Connection
, member_pid = MemberPid
, member_module = MemberModule
, session_timeout_seconds = SessionTimeoutSec
} = State) ->
ReqBody =
[ {group_id, GroupId}
, {generation_id, GenerationId}
, {member_id, MemberId}
, {group_assignment, assign_partitions(State)}
],
SessionTimeout = timer:seconds(SessionTimeoutSec),
SyncReq = brod_kafka_request:sync_group(Connection, ReqBody),
%% send sync group request and wait for response
RspBody = send_sync(Connection, SyncReq),
RspBody = send_sync(Connection, SyncReq, SessionTimeout),
%% get my partition assignments
Assignment = kpro:find(member_assignment, RspBody),
TopicAssignments = get_topic_assignments(State, Assignment),
Expand Down