chia7712 commented on code in PR #23569:
URL: https://github.com/apache/kafka/pull/23569#discussion_r4100224664


##########
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:
   I'm thinking how to fix the epoch files which have encountered this bug.
   
   1. If the earliest entry of the leader epoch cache has a start offset larger 
than the log start offset, we should add a warning message when the follower 
becomes a leader. This can be addressed in this PR.
   
   2. We should consider skipping the deletion of remote segments if the epoch 
cache is incomplete.
   
   3. If this bug happens on a follower only, it can rebuild the whole cache by 
resetting the fetch offset to the log start offset.
   
   Steps 2 and 3 could be the follow-ups. WDYT?



-- 
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]

Reply via email to