junrao commented on code in PR #16641:
URL: https://github.com/apache/kafka/pull/16641#discussion_r1686846223


##########
storage/src/main/java/org/apache/kafka/storage/internals/epoch/LeaderEpochFileCache.java:
##########
@@ -526,4 +524,13 @@ private void writeToFile() {
             lock.readLock().unlock();
         }
     }
+
+    private void writeToFileForTruncation() {
+        lock.readLock().lock();
+        try {
+            checkpoint.writeForTruncation(epochs.values());

Review Comment:
   Could we add a comment on why it's important to hold the lock while writing 
the checkpoint file?
   



##########
storage/src/main/java/org/apache/kafka/storage/internals/epoch/LeaderEpochFileCache.java:
##########
@@ -526,4 +524,13 @@ private void writeToFile() {
             lock.readLock().unlock();
         }
     }
+
+    private void writeToFileForTruncation() {

Review Comment:
   Perhaps it's clearer to rename this and `checkpoint.writeForTruncation` to 
sth like `writeIfDirExists`.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to