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


##########
core/src/main/java/kafka/server/TierStateMachine.java:
##########
@@ -157,17 +156,21 @@ private List<EpochEntry> 
readLeaderEpochCheckpoint(RemoteLogManager rlm,
         }
     }
 
+    private byte[] readProducerSnapshot(RemoteLogManager rlm,
+                                        RemoteLogSegmentMetadata 
remoteLogSegmentMetadata) throws IOException, RemoteStorageException {
+        try (InputStream inputStream = 
rlm.storageManager().fetchIndex(remoteLogSegmentMetadata, 
RemoteStorageManager.IndexType.PRODUCER_SNAPSHOT)) {
+            return inputStream.readAllBytes();

Review Comment:
   Could we keep flushing to tmp file? I don't see the obvious benefit to being 
in-memory 



##########
core/src/main/java/kafka/server/TierStateMachine.java:
##########
@@ -157,17 +156,21 @@ private List<EpochEntry> 
readLeaderEpochCheckpoint(RemoteLogManager rlm,
         }
     }
 
+    private byte[] readProducerSnapshot(RemoteLogManager rlm,
+                                        RemoteLogSegmentMetadata 
remoteLogSegmentMetadata) throws IOException, RemoteStorageException {
+        try (InputStream inputStream = 
rlm.storageManager().fetchIndex(remoteLogSegmentMetadata, 
RemoteStorageManager.IndexType.PRODUCER_SNAPSHOT)) {
+            return inputStream.readAllBytes();
+        }
+    }
+
     private void buildProducerSnapshotFile(UnifiedLog unifiedLog,

Review Comment:
   Could we just inline it? The correct order is listed below.
   
   1. Read the leader epoch checkpoint from remote
   2. Download the producer snapshot from remote to the temp file
   3. Truncate
   4. Assign the epochs
   5. Move the temp file (step 2) to the snapshot file
   6. Reload producer snapshots



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