Repository navigation
feat(binding-mqtt-kafka): delete the group offsets of the session on clean start - #3202
Merged
jfallows merged 2 commits intoNov 13, 2026
Conversation
…lean start On a Clean Start the session now asks the group coordinator for the group (FindCoordinator) and deletes the committed offsets of the group for the topic partitions it fetched (OffsetDelete v0), as raw api request streams, before the session offsets are fetched. The qos 2 clean start scenarios expect the exchange, and new scenarios cover version negotiation, a partition error, a group that is not found and a coordinator that is not available. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoXkbbzwjvWSZ2M9zor
…clean start On a Clean Start, once the partitions of the messages and retained topics are known and before the session offsets are fetched, the session resolves the group coordinator (FindCoordinator v3) and deletes the committed offsets of the group for those partitions (OffsetDelete v0) over raw api request streams, so a new session does not receive the backlog of the previous one. A failure of either request is not retried and does not fail the connect. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoXkbbzwjvWSZ2M9zor
This was referenced Nov 13, 2026
This was referenced Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Part of #3170 (the first part is #3184). On Clean Start=1 the session now deletes the committed offsets of the consumer group
<groupIdPrefix>-<clientId>for the topic partitions it knows, before the new session is established, so a client that asked for a fresh session is no longer sent the backlog of its previous session.How it works, on the path that already looks up the partitions (publish QoS max 2, the default):
apiRequeststream whose affinity is the coordinator's broker id from the FindCoordinator response. The client binding connects that stream to that broker (feat(binding-kafka): connect an api request stream to the broker named by its affinity #3198).Failure handling: the exchange is not retried and never fails the connect. A FindCoordinator error, a top-level OffsetDelete error, a per-partition error, a reset (including an unknown broker id), an abort or an unavailable stream all let the session continue. The OffsetDelete response is read to completion and its error codes are not acted on. The version negotiation of the raw API path (
apiChallengeanswered withapiFlush) is handled as inbinding-mcp-kafka.The code is a private abstract
KafkaApiRequestStreamwith two final subclasses (KafkaFindCoordinatorStream,KafkaOffsetDeleteStream) inMqttKafkaSessionFactory, besideKafkaOffsetFetchStream, plus a smallMqttKafkaOffsetDeleteSourcethat supplies the partitions to the OffsetDelete request codec.binding-mqtt-kafkanow depends onbinding-kafka(provided scope,requiresin module-info), asbinding-mcp-kafkadoes.This PR is based on #3200's branch (
fix/3199-k3po-read-option-affinity), the top of the current stack: #3184 <- #3181 <- #3185 <- #3198 <- #3200. It will be retargeted todevelopafter the PRs below it merge.Part of #3170
MQTT specification statements this change serves
(Same sections as #3184: v5.0 3.1.2.4, 3.1.2.11.2, 4.1, 4.1.1 and v3.1.1 3.1.2.4, 4.1, read in the full OASIS texts.)
The specifications do not mention consumer groups: they are an implementation detail of where the subscribe-side state lives.
Test evidence
Test-first: the first commit holds the scripts and ITs only; the second is the implementation.
publish.qos2,publish.qos2.no.prior.offsets,publish.qos2.retained,publish.qos2.offset.commit.abort.phase1,.phase2,publish.qos2.offset.fetch.abort,publish.qos2.init.producer.abort,publish.mixture.qos,session.clean.start.discard.offsets.session.clean.start.reset.group.offsets.negotiated,.partition.error,.group.not.found,.coordinator.not.available,.broker.zero. The per-partition error scenario pins that a partition error from the broker does not stop the session. It does not assert which error code a broker returns for a partition the group never committed.read option zilla:affinity(feat(engine): assert the affinity of a stream with read option zilla:affinity #3200), that the FindCoordinator stream has affinity 0 and the OffsetDelete stream has affinity 2..broker.zeroreturns broker 0 and asserts affinity 0.connected; the real order (reply after request) is exercised bybinding-kafka's own tests.Against unchanged production code (no group offset reset at all, measured earlier on
4dc43db067), 13 binding ITs failed (8 inMqttKafkaPublishProxyIT, 5 inMqttKafkaSessionProxyIT), each because the script expects the raw API stream the binding never opens. After the affinity assertions were added, with the reset implemented but opening the OffsetDelete stream at affinity 0, 12 binding ITs failed on this base (all of the above except.coordinator.not.available, which has no delete stream, and.broker.zero, which expects affinity 0), with "Expected affinity: 0x0000000000000002, but was: 0x0000000000000000". Several also time out on the retry run. The spec peer-to-peerKafkaITpasses throughout, so the scripts agree with each other.After the implementation,
clean verifywith checkstyle, license and notice checks on, build cache skipped, both modules (upstream modules installed with-amfirst):specs/binding-mqtt-kafka.spec: 279 ITs (KafkaIT155,MqttIT124), 0 failures, plus 27 unit and schema testsruntime/binding-mqtt-kafka: 160 ITs (MqttKafkaSubscribeProxyIT69,MqttKafkaSessionProxyIT46,MqttKafkaPublishProxyIT45), 0 failures, plus 10 unit testsNot delivered
KafkaSignalStream) has only the client id, so it would need its own meta lookups, coordinator lookup and delete, and the timing against a reconnecting client needs care. Tracked in mqtt-kafka: delete the consumer group offsets of a session when it expires #3204.publish.qos.maxbelow 2. Sessions on such a binding never fetch the partitions, so they do not run the reset: the partitions are not known. Four existing Clean Start scenarios run on that path. Tracked in mqtt-kafka: reset the group offsets on Clean Start when publish.qos.max is below 2 #3205.Follow-ups
publish.qos.maxbelow 2: mqtt-kafka: reset the group offsets on Clean Start when publish.qos.max is below 2 #3205.🤖 Generated with Claude Code
https://claude.ai/code/session_01SiHVoXkbbzwjvWSZ2M9zor