Browse Source

KAFKA-15312; Force channel before atomic file move (#14162)

On ext4 file systems we have seen snapshots with zero-length files. This is possible if
the file is closed and moved before forcing the channel to write to disk.

Reviewers: Ron Dagostino <rndgstn@gmail.com>, Alok Thatikunta <athatikunta@confluent.io>
pull/13975/merge
José Armando García Sancio 1 year ago committed by GitHub
parent
commit
e0727063f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      raft/src/main/java/org/apache/kafka/snapshot/FileRawSnapshotWriter.java

3
raft/src/main/java/org/apache/kafka/snapshot/FileRawSnapshotWriter.java

@ -112,6 +112,9 @@ public final class FileRawSnapshotWriter implements RawSnapshotWriter { @@ -112,6 +112,9 @@ public final class FileRawSnapshotWriter implements RawSnapshotWriter {
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()) {

Loading…
Cancel
Save