diff --git a/raft/src/main/java/org/apache/kafka/snapshot/FileRawSnapshotWriter.java b/raft/src/main/java/org/apache/kafka/snapshot/FileRawSnapshotWriter.java index 535c176c7280c..4dc1fe7da03d0 100644 --- a/raft/src/main/java/org/apache/kafka/snapshot/FileRawSnapshotWriter.java +++ b/raft/src/main/java/org/apache/kafka/snapshot/FileRawSnapshotWriter.java @@ -112,6 +112,9 @@ public void freeze() { checkIfFrozen("Freeze"); frozenSize = channel.size(); + // force the channel to write to the file system before closing, to make sure that the file has the data + // on disk before performing the atomic file move + channel.force(true); channel.close(); if (!tempSnapshotPath.toFile().setReadOnly()) {