From 9573bdd15e999a9de8669cfdc3db36f10bf8cbe9 Mon Sep 17 00:00:00 2001 From: Luke Chen Date: Thu, 21 Oct 2021 19:14:26 +0800 Subject: [PATCH 1/2] KAFKA-13391: don't fsync directory on Windows OS --- .../src/main/java/org/apache/kafka/common/utils/Utils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clients/src/main/java/org/apache/kafka/common/utils/Utils.java b/clients/src/main/java/org/apache/kafka/common/utils/Utils.java index be509bd1dffff..8acce6d31e752 100755 --- a/clients/src/main/java/org/apache/kafka/common/utils/Utils.java +++ b/clients/src/main/java/org/apache/kafka/common/utils/Utils.java @@ -948,10 +948,12 @@ public static void atomicMoveWithFallback(Path source, Path target, boolean need /** * Flushes dirty directories to guarantee crash consistency. * + * Note: We don't fsync directory on Windows OS because it'll throw AccessDeniedException (KAFKA-13391) + * * @throws IOException if flushing the directory fails. */ public static void flushDir(Path path) throws IOException { - if (path != null) { + if (path != null && !OperatingSystem.IS_WINDOWS) { try (FileChannel dir = FileChannel.open(path, StandardOpenOption.READ)) { dir.force(true); } From 6bd53f3ecd0011ba870d64e009e52f8999d5b620 Mon Sep 17 00:00:00 2001 From: Luke Chen Date: Fri, 22 Oct 2021 17:16:03 +0800 Subject: [PATCH 2/2] KAFKA-13391: address review comments ro rephrase comments --- clients/src/main/java/org/apache/kafka/common/utils/Utils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/src/main/java/org/apache/kafka/common/utils/Utils.java b/clients/src/main/java/org/apache/kafka/common/utils/Utils.java index 8acce6d31e752..a04f5c595bd3a 100755 --- a/clients/src/main/java/org/apache/kafka/common/utils/Utils.java +++ b/clients/src/main/java/org/apache/kafka/common/utils/Utils.java @@ -948,7 +948,7 @@ public static void atomicMoveWithFallback(Path source, Path target, boolean need /** * Flushes dirty directories to guarantee crash consistency. * - * Note: We don't fsync directory on Windows OS because it'll throw AccessDeniedException (KAFKA-13391) + * Note: We don't fsync directories on Windows OS because otherwise it'll throw AccessDeniedException (KAFKA-13391) * * @throws IOException if flushing the directory fails. */