Repository navigation
fix(binding-mqtt-kafka): delete the group offsets of a session when it expires - #3267
Merged
Merged
Conversation
…ion to be reset An expiring session must find the partitions of the messages and retained topics, find the group coordinator of <groupIdPrefix>-<clientId> and delete the group offsets for exactly those partitions, as the Clean Start path does. A client that connects while that reset is in flight is established only after the reset completes. Both scenarios fail against the current expiry handler, which only writes the session and session offsets tombstones. Refs #3204 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoWcvTJLQJnx15CWtWu
…t expires When a session expires, the expiry handler now opens a meta stream per messages topic and for the retained topic, finds the coordinator of the group <groupIdPrefix>-<clientId> and deletes the group offsets for exactly the partitions it learned, mirroring the Clean Start exchange. A client that connects while the reset is in flight is established after the reset completes. A coordinator or partition error skips the delete without a retry and releases the waiting connect. The meta and API request streams now report to a small delegate interface instead of the session proxy, so the same exchange serves a session and an expiry reset. Refs #3204 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoWcvTJLQJnx15CWtWu
…a-expiry-group-offsets Conflict in MqttKafkaSessionFactory: develop replaced the two-argument doMqttReset(traceId, EMPTY_OCTETS) calls with a one-argument doMqttReset(traceId) that carries the implementation specific error reason code. The meta stream now reports a reset through GroupOffsetsResetDelegate.onPartitionsReset, which the session proxy implements with the one-argument doMqttReset. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoWcvtJLQJnx15CWtWu
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
When an MQTT v5 session expires,
binding-mqtt-kafkaremoved the session record and the<clientId>#offsetsrecord but left the committed offsets of the consumer group<groupIdPrefix>-<clientId>in Kafka. A client connecting after expiry was handed the backlog of the expired session. The Clean Start path already deletes those group offsets (#3170, #3202); expiry now does the same.At expiry the signal stream opens a meta stream for each messages topic and for the retained topic, collects the partitions, finds the group coordinator and deletes the group offsets for exactly those partitions. This mirrors the Clean Start exchange of #3202 (meta streams, FindCoordinator, OffsetDelete). The meta and API request streams now report to a small
GroupOffsetsResetDelegateinterface instead of the session proxy, so the same exchange serves a session and an expiry reset.Design decisions (settled on the issue's design questions):
Specification statements (OASIS MQTT v5.0 text downloaded with curl and read from section 3.1.2.11.2 and sections 4.1 to 4.1.1; the rest of the document was not read line by line):
Kafka protocol documentation (kafka.apache.org/44/design/protocol, read for FindCoordinator (key 10) and OffsetDelete (key 47) request and response schemas and the error code table entries used here, not the whole page):
GROUP_SUBSCRIBED_TO_TOPIC(86): "Deleting offsets of a topic is forbidden while the consumer group is actively subscribed to it." The documentation does not say more about when a group counts as subscribed.Test evidence:
KafkaIT,MqttITandMqttKafkaSessionProxyITmethods. Run against the unchanged expiry handler, bothMqttKafkaSessionProxyITmethods (shouldResetGroupOffsetsOnSessionExpiry,shouldReconnectDuringSessionExpiryGroupOffsetsReset) fail: the server script never sees the meta stream for the reset, and the reconnecting client never connects because no OffsetDelete is issued.runtime/binding-mqtt-kafka(checkstyle, license and coverage checks on): 166 tests, 0 failures, including 51 inMqttKafkaSessionProxyIT. Clean verify ofspecs/binding-mqtt-kafka.specwith the build cache skipped:KafkaIT161 andMqttIT129 tests, 0 failures (run with-Dskip.checks=true; a run with module checks on and the cache skipped stops earlier in the unrelatedbuildmodule's NOTICE check, which cannot resolve two SNAPSHOT artifacts here).Fixes #3204
Not delivered
Generated by Claude Code