ocadaruma commented on code in PR #14242: URL: https://github.com/apache/kafka/pull/14242#discussion_r1374014105
########## storage/src/main/java/org/apache/kafka/storage/internals/log/ProducerStateManager.java: ########## @@ -462,22 +462,32 @@ public Optional<ProducerStateEntry> lastEntry(long producerId) { } /** - * Take a snapshot at the current end offset if one does not already exist. + * Take a snapshot at the current end offset if one does not already exist with syncing the change to the device */ public void takeSnapshot() throws IOException { + takeSnapshot(true); + } + + /** + * Take a snapshot at the current end offset if one does not already exist, then return the snapshot file if taken. + */ + public Optional<File> takeSnapshot(boolean sync) throws IOException { Review Comment: Thanks, that's a good point. I overlooked snapshot files would be cleaned up upon receiving `OffsetMovedToRemoteStorage`. In this case, if async flush is performed against non-existent file, it would throw IOException so we should catch it and ignore if it's NoSuchFileException. (Since file creation is still done in original thread. Only fsync is moved to async thread) I'll fix that -- 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