Skip to content

fix(binding-mqtt-kafka): write a group offsets request as the kafka credit allows - #3272

Merged
jfallows merged 3 commits into
fix/3204-mqtt-kafka-expiry-group-offsetsfrom
fix/3271-mqtt-kafka-request-stream-credit
Nov 17, 2026
Merged

jfallows merged 3 commits into
fix/3204-mqtt-kafka-expiry-group-offsetsfrom
fix/3271-mqtt-kafka-request-stream-credit

Conversation

@jfallows

Copy link
Copy Markdown
Contributor

Description

The request stream of a group offsets reset (KafkaApiRequestStream) built and sent its request once, on the first window, and skipped the request when that window was smaller than the request. A later, larger window did not help. For the OffsetDelete request (81 bytes plus padding) a first window of 67 bytes meant the delete was silently skipped.

Credit is a contract in every direction: a sender with more to write than the window allows waits for the next window. The request stream now holds the request in an encode slot and writes as much as each window allows, INIT on the first fragment and FIN on the last. It fails only when the stream ends, aborts or is reset before enough credit arrives.

Pattern mirrored: KafkaClientApiFactory.encodeNet in binding-kafka (the consumer of this very stream), which writes up to the available credit minus padding, keeps the remainder in encodeSlot and flushes it on the next WINDOW. No reserve, slack or flag is added; the remaining length and the first fragment are derived from encodeSlotOffset / encodeSlotLimit.

Test evidence

  • New scenario session.close.expire.session.reset.group.offsets.small.window (kafka client/server pair): the kafka peer grants 67 bytes first, then 8192 on each stream.
    • KafkaIT.shouldResetGroupOffsetsOnSessionExpiryAfterSmallWindow (spec pair): passes.
    • MqttKafkaSessionProxyIT.shouldResetGroupOffsetsOnSessionExpiryAfterSmallWindow: fails before the change (the OffsetDelete stream is closed without its request being written), passes after.
  • ./mvnw clean verify with the build cache skipped: specs/binding-mqtt-kafka.spec 291 tests (MqttIT 129, KafkaIT 162), runtime/binding-mqtt-kafka 167 ITs plus 10 unit tests, all passing; checkstyle:check and license:format clean.

Not delivered

  • The FindCoordinator request shares the same stream and gets the same behaviour, but has no dedicated small-window scenario.
  • No change to how a failed or skipped delete is reported beyond the existing completion path.

Fixes #3271


Generated by Claude Code

…credit

An OffsetDelete request of 81 bytes plus padding must be written once the kafka
peer grants enough credit, when the first window it grants is smaller than the
request.

The scenario fails against the current request stream, which sends once on the
first window and skips the request when that window is too small.

Refs #3271

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SiHVoUxB2kGhP16gREH2uz
…redit allows

The request stream of a group offsets reset built and sent its request once, on
the first window, and skipped it when that window was smaller than the request.

It now holds the request in an encode slot and writes as much as each window
allows, with INIT on the first fragment and FIN on the last, as the kafka client
api stream does for a request that does not fit the current window. It fails
only when the stream ends, aborts or is reset before enough credit arrives.

Fixes #3271

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SiHVoUxB2kGhP16gREH2uz
…-offsets' into fix/3271-mqtt-kafka-request-stream-credit
@jfallows
jfallows merged commit cac45fe into develop Nov 17, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mqtt-kafka: a group offsets request is skipped when the first window is smaller than the request instead of waiting for credit

2 participants