You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by js...@apache.org on 2023/08/08 22:07:33 UTC
[kafka] branch 3.4 updated: KAFKA-15312; Force channel before atomic file move (#14162)
This is an automated email from the ASF dual-hosted git repository.
jsancio pushed a commit to branch 3.4
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/3.4 by this push:
new a33681d7826 KAFKA-15312; Force channel before atomic file move (#14162)
a33681d7826 is described below
commit a33681d7826ab3298a50c9c63fb41ab647c4ed3a
Author: José Armando García Sancio <js...@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 <rn...@gmail.com>, Alok Thatikunta <at...@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;