Repository navigation
fix(binding-kafka): retry init producer id on retriable errors - #3104
Merged
jfallows merged 8 commits intoNov 16, 2026
Merged
Conversation
A Kafka broker that has just started answers the first InitProducerId request with COORDINATOR_LOAD_IN_PROGRESS (14), and may answer COORDINATOR_NOT_AVAILABLE (15), until its producer id state is loaded. Both are transient, but the init producer id client treated every non-zero error as fatal and reset the application stream, so callers saw a failure for a request that succeeds moments later. Retry the request on these two errors, as the group client already does for FindCoordinator, and keep every other error code fatal. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoU937V4jRec4nwtVJe
6 tasks done
…session stream is reset Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoV4YmVnkN6i2vWSkDo
…eason code valid for the packet A reset of the mqtt session stream with no reason code was mapped to 0x8E (session taken over), which is not a valid CONNACK reason code. The mqtt-kafka session factory now resets with implementation specific error (0x83) when a kafka stream fails, and the mqtt server defaults a bare reset to 0x83, never encodes a reason code invalid in CONNACK, and keeps 0x8E for a real takeover. Refs #3101 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoV4YmVnkN6i2vWSkDo
… the v4 return code for a reset session Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoV4YmVnkN6i2vWSkDo
…ble return code A v4 CONNACK only carries return codes 0 to 5, so a session stream reset before CONNACK is answered with server unavailable (3). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoV4YmVnkN6i2vWSkDo
…cer id error Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoV4YmVnkN6i2vWSkDo
…ackoff The init producer id client retries the request when KafkaError reports the response error as retriable, delayed with the exponential backoff capped by the client reconnect delay, and resets the application stream with the error for any other error. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoV4YmVnkN6i2vWSkDo
This was referenced Nov 17, 2026
Closed
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
Root cause. A freshly started Kafka broker answers the first
InitProducerIdrequest with a retriable error,COORDINATOR_LOAD_IN_PROGRESS(14) orCOORDINATOR_NOT_AVAILABLE(15), until its producer id state is loaded; the same request succeeds a few hundred milliseconds later (observed againstapache/kafka:4.1.1: error 14 on the first attempt, success on the next, about 0.3s later).KafkaClientInitProducerIdFactorytreated every non-zero error code as fatal and reset the application stream. Inmqtt-kafka, that reset on the session's init-producer stream carries no reason code, so the MQTT server maps it to0x8E(session taken over), and that code was even sent in a CONNACK where it is not valid. The client ids were never in conflict; the session was simply failed by a transient broker error.Fix.
KafkaErrorreports the response error as retriable, instead of a fixed pair of codes. The retry is delayed with the exponential backoff the other clients use (50 << attempt, capped by the existingzilla.binding.kafka.client.reconnectdelay, mirroringKafkaClientApiFactory) and is cancelled when the stream closes. Every non-retriable error still resets the application stream with the Kafka error.0x8E. Themqtt-kafkasession factory resets the MQTT session with implementation specific error (0x83) when a Kafka stream fails, mirroring the existing compact-policy path. The MQTT server defaults a reset without a reason code to0x83instead of0x8E, never encodes a reason code that is invalid in a CONNACK, and keeps0x8Efor a real session takeover. A v4 client is answered with return code 3 (server unavailable), since a v4 CONNACK only carries return codes 0 to 5.develop.Tests (test-first).
init.producer.id.v4/produce.new.id.coordinator.load.in.progress,.coordinator.not.available,.request.timed.out(a retriable error beyond 14 and 15) and.cluster.authorization.failed(non-retriable, reset immediately, with an application scenario too), plusInitProducerIdITandClientInitProducerIdITmethods for each.session.server.sent.reset.before.connackandafter.connack(MQTT server, v5, plus v4 before CONNACK), andsession.qos2.meta.reset,session.qos2.init.producer.resetandsession.qos2.offset.fetch.reset(mqtt-kafka). The existing v4session.reject.non.compacted.sessions.topicscript now expects return code 3../mvnw verify(checkstyle, license, jacoco and all ITs) onspecs/binding-kafka.spec,specs/binding-mqtt.spec,specs/binding-mqtt-kafka.spec,runtime/binding-kafka,runtime/binding-mqttandruntime/binding-mqtt-kafka: BUILD SUCCESS, 0 failures.examples/mqtt.kafka.proxy,apache/kafka:4.1.1, fresh stack each run): ondevelop62 of 63 connects were rejected with0x8E(single client and 20 concurrent clients, three runs each); on this branch all 66 connected and subscribed with CONNACK 0, including with the backoff retry.Reused-stack rejections in a QoS 1 ramp traced to a separate group assignment crash, fixed by #3292.
Fixes #3101
Generated by Claude Code