forked from apache/kafka
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KAFKA-10312; Fix error code returned in Metadata response when leader…
… is not available (apache#9112) MetadataCache#getPartitionMetadata returns an error when the topic's leader Id is present at MetadataCache but listener endpoint is not present for this leader. For older versions, LEADER_NOT_AVAILABLE is returned while LISTENER_NOT_FOUND is returned for new metadata versions. The problem is that getPartitionMetadata was looking up MetadataCache's host brokerId rather than the topic's leader id while determining what error to return. This could result in the call returning LISTENER_NOT_FOUND when it should have returned LEADER_NOT_AVAILABLE. This commit corrects this behavior. Unit tests were already present to test out the error codes returned under different situations but they were giving out a false positive. The test was using same broker id for both the MetadataCache's host as well as for the topic's leader. Error manifests when the MetadataCache's host id is changed. Improved the test. This commit also consolidated couple of related tests to reduce code duplication. Reviewers: Jason Gustafson <[email protected]>
- Loading branch information
1 parent
8af7b96
commit f19cd6c
Showing
2 changed files
with
15 additions
and
36 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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