Internals: Group Coordinator
This chapter focuses on consumer-group mechanics.
Group State Model
Each group tracks:
topicgenerationassignormemberswith heartbeat timestamps- partition
assignments
Lifecycle Commands
JOIN: add/refresh member and possibly trigger rebalanceSYNC: confirm generation and get assignmentHEARTBEAT: maintain liveness in current generationLEAVE: explicit member removal and rebalanceCOMMIT: validated offset commit
Generation Rules
Generation increments when:
- new member joins
- member expires by session timeout
- member leaves
- assignor changes
- topic context changes for the group
Session Timeout Handling
Expired members are removed when coordinator evaluates group state.
Effects:
- generation bumps
- assignments recalculated
- stale members become invalid for commit/heartbeat/sync
Commit Fencing
COMMIT is rejected unless all are true:
- group and topic match
- generation is current
- member exists
- partition is assigned to that member
This is the key stale-writer safety mechanism.
Durability
Group metadata persists to groups.json.
On restart:
- generation and assignment state reloads
- members restore with last heartbeat timestamps
- lifecycle resumes from persisted state