showuon commented on code in PR #13456:
URL: https://github.com/apache/kafka/pull/13456#discussion_r1154310401


##########
storage/src/main/java/org/apache/kafka/storage/internals/epoch/LeaderEpochFileCache.java:
##########
@@ -383,21 +398,25 @@ public void clear() {
 
     // Visible for testing
     public List<EpochEntry> epochEntries() {
-        lock.writeLock().lock();
+        lock.readLock().lock();
         try {
             return new ArrayList<>(epochs.values());
         } finally {
-            lock.writeLock().unlock();
+            lock.readLock().unlock();
         }
     }
 
-    private void flush() {
+    private void flushTo(LeaderEpochCheckpoint leaderEpochCheckpoint, 
Collection<EpochEntry> epochEntries) {
         lock.readLock().lock();
         try {
-            checkpoint.write(epochs.values());
+            leaderEpochCheckpoint.write(epochEntries);
         } finally {
             lock.readLock().unlock();
         }
     }
 
+    private void flush() {
+        flushTo(this.checkpoint, epochs.values());

Review Comment:
   No, the 2nd parameter is different. For `in memory` one, we need to "clone" 
the epochs values to avoid change the inner entries. 



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