This is an automated email from the ASF dual-hosted git repository.

jsancio pushed a commit to branch 3.5
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/3.5 by this push:
     new 0e739901887 KAFKA-15312; Force channel before atomic file move (#14162)
0e739901887 is described below

commit 0e739901887b5a0195e274a1085c7de43d9c104b
Author: José Armando García Sancio <jsan...@users.noreply.github.com>
AuthorDate: Tue Aug 8 14:31:42 2023 -0700

    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 <rndg...@gmail.com>, Alok Thatikunta 
<athatiku...@confluent.io>
---
 .../src/main/java/org/apache/kafka/snapshot/FileRawSnapshotWriter.java | 3 +++
 1 file changed, 3 insertions(+)

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 badefd321ed..54775123f73 100644
--- a/raft/src/main/java/org/apache/kafka/snapshot/FileRawSnapshotWriter.java
+++ b/raft/src/main/java/org/apache/kafka/snapshot/FileRawSnapshotWriter.java
@@ -107,6 +107,9 @@ public final class FileRawSnapshotWriter implements 
RawSnapshotWriter {
         try {
             checkIfFrozen("Freeze");
 
+            // 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();
             frozen = true;
 

Reply via email to