FrankYang0529 commented on code in PR #16660:
URL: https://github.com/apache/kafka/pull/16660#discussion_r1688340519
##########
storage/src/main/java/org/apache/kafka/storage/internals/epoch/LeaderEpochFileCache.java:
##########
@@ -525,10 +525,13 @@ private void writeToFile() {
}
}
- private void writeToFileForTruncation() {
+ private void writeIfDirExists() {
lock.readLock().lock();
try {
- checkpoint.writeForTruncation(epochs.values());
+ // Write epoch entries under the read lock to avoid older epoch
entries overwriting the newer epoch entries.
+ // If we take a snapshot of the epoch entries here and flush to
disk outside the read lock,
+ // the leader epoch file may have correctness issue, because the
new epoch entry may already in the file.
Review Comment:
Thanks for the review and suggestion. Updated it.
--
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]