-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-9840: Skip End Offset validation when the leader epoch is not reliable #8486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
fddb49e
dbaa133
94e0911
03407c4
a6c0785
6a66b1b
1a97ccc
87ca234
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,9 +40,7 @@ public EpochEndOffset(Errors error, int leaderEpoch, long endOffset) { | |
| } | ||
|
|
||
| public EpochEndOffset(int leaderEpoch, long endOffset) { | ||
| this.error = Errors.NONE; | ||
| this.leaderEpoch = leaderEpoch; | ||
| this.endOffset = endOffset; | ||
| this(Errors.NONE, leaderEpoch, endOffset); | ||
| } | ||
|
|
||
| public Errors error() { | ||
|
|
@@ -86,4 +84,9 @@ public boolean equals(Object o) { | |
| public int hashCode() { | ||
| return Objects.hash(error, leaderEpoch, endOffset); | ||
| } | ||
|
|
||
| public boolean hasUndefinedEpochOrOffset() { | ||
| return this.endOffset == UNDEFINED_EPOCH_OFFSET || | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For my own understanding: if endOffset is UNDEFINED the epoch should always be UNDEFINED too? If that's the case we can just rely on
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just feel this check is stronger if later we change the behavior on broker.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Older versions did not return the epoch, so it was possible to see an offset defined without an epoch. However, the version that the consumer relies on should always have both or neither. Anyway, I think it is reasonable to be a little stricter here. |
||
| this.leaderEpoch == UNDEFINED_EPOCH; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -371,7 +371,7 @@ public PartitionMetadata withoutLeaderEpoch() { | |
| @Override | ||
| public String toString() { | ||
| return "PartitionMetadata(" + | ||
| ", error=" + error + | ||
| "error=" + error + | ||
| ", partition=" + topicPartition + | ||
| ", leader=" + leaderId + | ||
| ", leaderEpoch=" + leaderEpoch + | ||
|
|
@@ -429,7 +429,8 @@ private Collection<TopicMetadata> createTopicMetadata(MetadataResponseData data) | |
|
|
||
| public static MetadataResponse prepareResponse(int throttleTimeMs, Collection<Node> brokers, String clusterId, | ||
| int controllerId, List<TopicMetadata> topicMetadataList, | ||
| int clusterAuthorizedOperations) { | ||
| int clusterAuthorizedOperations, | ||
| short responseVersion) { | ||
| MetadataResponseData responseData = new MetadataResponseData(); | ||
| responseData.setThrottleTimeMs(throttleTimeMs); | ||
| brokers.forEach(broker -> | ||
|
|
@@ -464,22 +465,41 @@ public static MetadataResponse prepareResponse(int throttleTimeMs, Collection<No | |
| } | ||
| responseData.topics().add(metadataResponseTopic); | ||
| }); | ||
| return new MetadataResponse(responseData); | ||
| return new MetadataResponse(responseData.toStruct(responseVersion), responseVersion); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change the function signature to be able to pass in response version. |
||
| } | ||
|
|
||
| public static MetadataResponse prepareResponse(int throttleTimeMs, Collection<Node> brokers, String clusterId, | ||
| int controllerId, List<TopicMetadata> topicMetadataList) { | ||
| public static MetadataResponse prepareResponse(int throttleTimeMs, | ||
| Collection<Node> brokers, | ||
| String clusterId, | ||
| int controllerId, | ||
| List<TopicMetadata> topicMetadataList, | ||
| short responseVersion) { | ||
| return prepareResponse(throttleTimeMs, brokers, clusterId, controllerId, topicMetadataList, | ||
| MetadataResponse.AUTHORIZED_OPERATIONS_OMITTED); | ||
| MetadataResponse.AUTHORIZED_OPERATIONS_OMITTED, responseVersion); | ||
| } | ||
|
|
||
| public static MetadataResponse prepareResponse(Collection<Node> brokers, | ||
| String clusterId, | ||
| int controllerId, | ||
| List<TopicMetadata> topicMetadata, | ||
| short responseVersion) { | ||
| return prepareResponse(AbstractResponse.DEFAULT_THROTTLE_TIME, brokers, clusterId, controllerId, | ||
| topicMetadata, responseVersion); | ||
| } | ||
|
|
||
| public static MetadataResponse prepareResponse(Collection<Node> brokers, String clusterId, int controllerId, | ||
| public static MetadataResponse prepareResponse(Collection<Node> brokers, | ||
| String clusterId, | ||
| int controllerId, | ||
| List<TopicMetadata> topicMetadata) { | ||
| return prepareResponse(AbstractResponse.DEFAULT_THROTTLE_TIME, brokers, clusterId, controllerId, topicMetadata); | ||
| return prepareResponse(AbstractResponse.DEFAULT_THROTTLE_TIME, brokers, clusterId, controllerId, | ||
| topicMetadata, ApiKeys.METADATA.latestVersion()); | ||
| } | ||
|
|
||
| public static MetadataResponse prepareResponse(int throttleTimeMs, List<MetadataResponseTopic> topicMetadataList, | ||
| Collection<Node> brokers, String clusterId, int controllerId, | ||
| public static MetadataResponse prepareResponse(int throttleTimeMs, | ||
| List<MetadataResponseTopic> topicMetadataList, | ||
| Collection<Node> brokers, | ||
| String clusterId, | ||
| int controllerId, | ||
| int clusterAuthorizedOperations) { | ||
| MetadataResponseData responseData = new MetadataResponseData(); | ||
| responseData.setThrottleTimeMs(throttleTimeMs); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.