dybyte commented on code in PR #23569:
URL: https://github.com/apache/kafka/pull/23569#discussion_r4103150574
##########
core/src/main/java/kafka/server/TierStateMachine.java:
##########
@@ -243,20 +246,24 @@ private Long buildRemoteLogAuxState(TopicPartition
topicPartition,
// Assign nextOffset with the offset from which next fetch should
happen.
long nextOffset = remoteLogSegmentMetadata.endOffset() + 1;
- // Truncate the existing local log before restoring the leader epoch
cache and producer snapshots.
+ // Read everything needed from remote storage before modifying the
local log, so that a failed read
+ // leaves the local log and its leader epoch cache untouched and the
next fetch retries this state machine.
+ List<EpochEntry> epochs = readLeaderEpochCheckpoint(rlm,
remoteLogSegmentMetadata);
Review Comment:
Thanks, sounds good to me.
1. Added. When a partition becomes the leader, RemoteLogManager logs a
warning if the log has a remote range (logStartOffset < localLogStartOffset)
and the epoch cache is empty or starts after logStartOffset. The check is a
separate method so 2 and 3 can reuse it.
2. +1. I verified with a local test that the unreferenced-epoch cleanup
deletes all remote segments of the lost epochs in this state. Such a leader
also uploads its incomplete checkpoint with every new segment, so followers
that later rebuild from it inherit the gap. What do you think about also
skipping the copy while the cache is incomplete, using the same check? The cost
is that local segments cannot be deleted until they are copied, so disk usage
grows until leadership moves to a healthy replica. Is that a reasonable
direction, or is the warning enough for this case?
3. +1, but I'd truncate the local log to logStartOffset before refetching.
After a restart the follower's logStartOffset can lag the leader's, and then
OFFSET_OUT_OF_RANGE makes the fetcher resume from the local log end offset,
skipping the rebuild.
Neither 2 nor 3 fixes a replica that is already the leader. I'll open a
follow-up JIRA for 2 and 3 and mention that there.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]