-
Notifications
You must be signed in to change notification settings - Fork 14k
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
MINOR: Introduce OffsetAndEpoch in LeaderEndpoint interface return values #13268
MINOR: Introduce OffsetAndEpoch in LeaderEndpoint interface return values #13268
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kowshik : Thanks for the PR. Left a comment. Also, the built failed with unused import.
|
||
package kafka.server | ||
|
||
case class OffsetAndEpoch(offset: Long, leaderEpoch: Int) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add this in the server-common module in java?
02b0518
to
99cafb8
Compare
@junrao Thanks for the review! I've addressed the comments, the PR is ready for another pass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @kowshik for the updated PR, LGTM.
warn(s"Reset fetch offset for partition $topicPartition from $replicaEndOffset to current " + | ||
s"leader's start offset $leaderStartOffset") | ||
val offsetToFetch = | ||
if (leaderStartOffset > replicaEndOffset) { | ||
// Only truncate log when current leader's log start offset (local log start offset if >= 3.4 version incaseof | ||
// OffsetMovedToTieredStorage error) is greater than follower's log end offset. | ||
// truncateAndBuild returns offset value from which it needs to start fetching. | ||
truncateAndBuild(epoch, leaderStartOffset) | ||
truncateAndBuild(offsetAndEpoch.leaderEpoch, leaderStartOffset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor - maybe the argument of truncateAndBuild
could be the offsetAndEpoch
itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 3da1e63. Good point!
@Hangleton Thanks for the review. I have addressed the comment, the PR is ready for another pass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kowshik : Thanks for the updated PR. Could you rebase?
3da1e63
to
484eef1
Compare
@junrao Thanks for the review. I have rebased the PR and brought in the latest commits from AK trunk. PR is ready for a pass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kowshik : Thanks for rebasing the PR. LGTM
Thanks! |
Some of the
LeaderEndpoint
interface methods used a tuple of(Int, Long)
as return value to represent epoch & offset. In this PR, I have replaced those occcurences with the existingOffsetAndEpoch
type. This should hopefully improve code readability, and eliminate the chances of developer confusing offset with epoch (or vice versa) at the call site or return site.Tests:
Rely on existing tests