Fix: Persistent broker reconnection failure detection and DNS re-resolution #5267
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.
Add persistent broker reconnection failure detection and DNS re-resolution
Problem
When a Kafka broker node restarts or updates—particularly with AWS IAM authentication via SASL over private links in cross-account AWS MSK setups—librdkafka silently fails to reconnect without surfacing actionable errors to the application. This forces users to completely destroy and recreate consumers/producers to recover, as there's no signal indicating the persistent failure.
Root causes:
Solution
1. New Error Code:
RD_KAFKA_RESP_ERR__BROKER_PERSISTENT_FAILURE(-136)Signals when broker reconnection has been failing persistently, delivered via the error callback.
2. New Configuration:
reconnect.failure.report.msreconnect.failure.report.ms3. DNS Re-resolution on Auth Failures
Address cache is automatically cleared on authentication failures to force DNS re-resolution, addressing scenarios where broker IPs change after restarts.
Usage
Behavior
reconnect.failure.report.ms=0disables the featureALL_BROKERS_DOWNbehavior is unchangedFiles Changed
src/rdkafka.h- New error codesrc/rdkafka.c- Error descriptionsrc/rdkafka_conf.h/src/rdkafka_conf.c- New configuration optionsrc/rdkafka_broker.h/src/rdkafka_broker.c- Failure tracking and DNS re-resolution logicCONFIGURATION.md- Documentationtests/0154-persistent_broker_failure.c- Integration testsTesting
Breaking Changes
None. Additive change with backward-compatible defaults.