KAFKA-20393: Fix stickyNode using stale IP when broker address changes#21983
Merged
apoorvmittal10 merged 2 commits intoapache:trunkfrom Apr 9, 2026
Merged
KAFKA-20393: Fix stickyNode using stale IP when broker address changes#21983apoorvmittal10 merged 2 commits intoapache:trunkfrom
apoorvmittal10 merged 2 commits intoapache:trunkfrom
Conversation
Signed-off-by: Daeho Kwon <trewq231@naver.com>
harimm
reviewed
Apr 7, 2026
clients/src/main/java/org/apache/kafka/clients/NetworkClient.java
Outdated
Show resolved
Hide resolved
kwondh5217
commented
Apr 8, 2026
clients/src/main/java/org/apache/kafka/clients/NetworkClient.java
Outdated
Show resolved
Hide resolved
Contributor
apoorvmittal10
left a comment
There was a problem hiding this comment.
Thanks for the PR and fix, I have left some comments.
clients/src/main/java/org/apache/kafka/clients/NetworkClient.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Daeho Kwon <trewq231@naver.com>
apoorvmittal10
approved these changes
Apr 9, 2026
Contributor
apoorvmittal10
left a comment
There was a problem hiding this comment.
Thanks for the changes, LGTM. I ll merge once build completes.
Contributor
Author
|
@apoorvmittal10 , Thank you for the review! |
apoorvmittal10
pushed a commit
that referenced
this pull request
Apr 9, 2026
#21983) When a broker's IP address changes (e.g., pod replacement in Kubernetes), `TelemetrySender.stickyNode` retains a stale `Node` object with the old address. Since `canSendRequest()` checks by node ID only, the stale connection passes the check and telemetry data is sent to the wrong host. This PR refreshes `stickyNode` against current metadata at the start of `TelemetrySender.maybeUpdate()`. If the node's address has changed, `stickyNode` is updated to the fresh `Node`. If the node no longer exists in metadata, `stickyNode` is cleared and reconnect backoff is returned. Reviewers: Apoorv Mittal <apoorvmittal10@gmail.com> --------- Signed-off-by: Daeho Kwon <trewq231@naver.com>
Contributor
|
Cherry-picked to 4.2 branch as well. |
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.
When a broker's IP address changes (e.g., pod replacement in
Kubernetes),
TelemetrySender.stickyNoderetains a staleNodeobject with the old address. Since
canSendRequest()checks by nodeID only, the stale connection passes the check and telemetry data is
sent to the wrong host.
This PR refreshes
stickyNodeagainst current metadata at the start ofTelemetrySender.maybeUpdate(). If the node's address has changed,stickyNodeis updated to the freshNode. If the node no longerexists in metadata,
stickyNodeis cleared and reconnect backoff isreturned.
Reviewers: Apoorv Mittal apoorvmittal10@gmail.com