Skip to content

Fix fuse_dfs flush skipping hdfsHFlush when fi->flags is 0#8545

Open
shanrui wants to merge 3 commits into
apache:trunkfrom
shanrui:HDFS-fuse-flush-fix
Open

Fix fuse_dfs flush skipping hdfsHFlush when fi->flags is 0#8545
shanrui wants to merge 3 commits into
apache:trunkfrom
shanrui:HDFS-fuse-flush-fix

Conversation

@shanrui

@shanrui shanrui commented Jun 11, 2026

Copy link
Copy Markdown

Problem:
In modern libfuse implementations, fi->flags in flush() callback
may be reset to 0. The original fuse_dfs code relies on:

if (fi->flags & O_WRONLY)
As a result, hdfsHFlush/hdfsHSync is skipped, causing newly written
data to be invisible to readers until file close.

Root cause:
fi->flags is not guaranteed to be preserved in flush().

Fix:
Store open flags in dfs_fh during dfs_open(), and use it in flush()
instead of fi->flags.

Testing:

Verified write -> flush -> read consistency
Verified hdfsHFlush is triggered correctly

@shanrui

shanrui commented Jun 11, 2026

Copy link
Copy Markdown
Author

@ajfabbri May i ask a review on this?
Thanks!

@hadoop-yetus

Copy link
Copy Markdown

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 9m 24s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 1s codespell was not available.
+0 🆗 detsecrets 0m 1s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
-1 ❌ test4tests 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
_ trunk Compile Tests _
+1 💚 mvninstall 30m 44s trunk passed
+1 💚 compile 3m 2s trunk passed with JDK Red Hat, Inc.-21.0.11+10-LTS
+1 💚 compile 3m 3s trunk passed with JDK Red Hat, Inc.-17.0.19+10-LTS
+1 💚 mvnsite 1m 23s trunk passed
+1 💚 shadedclient 55m 43s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 2m 8s the patch passed
+1 💚 compile 2m 10s the patch passed with JDK Red Hat, Inc.-21.0.11+10-LTS
+1 💚 cc 2m 10s the patch passed
+1 💚 golang 2m 10s the patch passed
+1 💚 javac 2m 10s the patch passed
+1 💚 compile 2m 7s the patch passed with JDK Red Hat, Inc.-17.0.19+10-LTS
+1 💚 cc 2m 7s the patch passed
+1 💚 golang 2m 7s the patch passed
+1 💚 javac 2m 7s the patch passed
-1 ❌ blanks 0m 0s /blanks-eol.txt The patch has 1 line(s) that end in blanks. Use git apply --whitespace=fix <<patch_file>>. Refer https://git-scm.com/docs/git-apply
+1 💚 mvnsite 0m 25s the patch passed
+1 💚 shadedclient 16m 1s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 6m 27s hadoop-hdfs-native-client in the patch passed.
+1 💚 asflicense 0m 41s The patch does not generate ASF License warnings.
97m 25s
Subsystem Report/Notes
Docker ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8545/1/artifact/out/Dockerfile
GITHUB PR #8545
Optional Tests dupname asflicense compile cc mvnsite javac unit codespell detsecrets golang
uname Linux 904320cd3da6 5.15.0-181-generic #191-Ubuntu SMP Fri May 22 19:09:02 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / c858bdf
Default Java Red Hat, Inc.-17.0.19+10-LTS
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-21.0.11.0.10-1.el8_10.x86_64:Red Hat, Inc.-21.0.11+10-LTS /usr/lib/jvm/java-17-openjdk-17.0.19.0.10-1.el8_10.x86_64:Red Hat, Inc.-17.0.19+10-LTS
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8545/1/testReport/
Max. process+thread count 743 (vs. ulimit of 10000)
modules C: hadoop-hdfs-project/hadoop-hdfs-native-client U: hadoop-hdfs-project/hadoop-hdfs-native-client
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8545/1/console
versions git=2.43.7 maven=3.9.15
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@hadoop-yetus

Copy link
Copy Markdown

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 7m 28s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 1s codespell was not available.
+0 🆗 detsecrets 0m 1s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
-1 ❌ test4tests 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
_ trunk Compile Tests _
+1 💚 mvninstall 19m 20s trunk passed
+1 💚 compile 2m 2s trunk passed
+1 💚 mvnsite 0m 31s trunk passed
+1 💚 shadedclient 37m 46s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 1m 43s the patch passed
+1 💚 compile 1m 43s the patch passed
+1 💚 cc 1m 43s the patch passed
+1 💚 golang 1m 43s the patch passed
+1 💚 javac 1m 43s the patch passed
-1 ❌ blanks 0m 0s /blanks-eol.txt The patch has 1 line(s) that end in blanks. Use git apply --whitespace=fix <<patch_file>>. Refer https://git-scm.com/docs/git-apply
+1 💚 mvnsite 0m 14s the patch passed
+1 💚 shadedclient 15m 7s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 5m 47s hadoop-hdfs-native-client in the patch passed.
+1 💚 asflicense 0m 23s The patch does not generate ASF License warnings.
72m 3s
Subsystem Report/Notes
Docker ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8545/1/artifact/out/Dockerfile
GITHUB PR #8545
Optional Tests dupname asflicense compile cc mvnsite javac unit codespell detsecrets golang
uname Linux 6457ae4619a1 5.15.0-181-generic #191-Ubuntu SMP Fri May 22 19:09:02 UTC 2026 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / c858bdf
Default Java Debian-25.0.3+9-2-deb13u1-Debian
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8545/1/testReport/
Max. process+thread count 587 (vs. ulimit of 10000)
modules C: hadoop-hdfs-project/hadoop-hdfs-native-client U: hadoop-hdfs-project/hadoop-hdfs-native-client
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8545/1/console
versions git=2.47.3 maven=3.9.15
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@hadoop-yetus

Copy link
Copy Markdown

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 23s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 1s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
-1 ❌ test4tests 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
_ trunk Compile Tests _
+1 💚 mvninstall 20m 25s trunk passed
+1 💚 compile 2m 1s trunk passed with JDK Ubuntu-21.0.11+10-1-24.04.2-Ubuntu
+1 💚 compile 2m 0s trunk passed with JDK Ubuntu-17.0.19+10-1-24.04.2-Ubuntu
+1 💚 mvnsite 0m 31s trunk passed
+1 💚 shadedclient 41m 8s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 1m 43s the patch passed
+1 💚 compile 1m 39s the patch passed with JDK Ubuntu-21.0.11+10-1-24.04.2-Ubuntu
+1 💚 cc 1m 39s the patch passed
+1 💚 golang 1m 39s the patch passed
+1 💚 javac 1m 39s the patch passed
+1 💚 compile 1m 41s the patch passed with JDK Ubuntu-17.0.19+10-1-24.04.2-Ubuntu
+1 💚 cc 1m 41s the patch passed
+1 💚 golang 1m 41s the patch passed
+1 💚 javac 1m 41s the patch passed
-1 ❌ blanks 0m 0s /blanks-eol.txt The patch has 1 line(s) that end in blanks. Use git apply --whitespace=fix <<patch_file>>. Refer https://git-scm.com/docs/git-apply
+1 💚 mvnsite 0m 14s the patch passed
+1 💚 shadedclient 15m 13s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 6m 6s hadoop-hdfs-native-client in the patch passed.
+1 💚 asflicense 0m 24s The patch does not generate ASF License warnings.
70m 20s
Subsystem Report/Notes
Docker ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8545/1/artifact/out/Dockerfile
GITHUB PR #8545
Optional Tests dupname asflicense compile cc mvnsite javac unit codespell detsecrets golang
uname Linux 03aebbfa3319 5.15.0-181-generic #191-Ubuntu SMP Fri May 22 19:09:02 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / c858bdf
Default Java Ubuntu-17.0.19+10-1-24.04.2-Ubuntu
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.11+10-1-24.04.2-Ubuntu /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.19+10-1-24.04.2-Ubuntu
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8545/1/testReport/
Max. process+thread count 612 (vs. ulimit of 10000)
modules C: hadoop-hdfs-project/hadoop-hdfs-native-client U: hadoop-hdfs-project/hadoop-hdfs-native-client
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8545/1/console
versions git=2.43.0 maven=3.9.15
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@ajfabbri

Copy link
Copy Markdown
Contributor

Thanks for the PR. This needs a Jira which describes the bug and how it manifests. Please use our PR template for the main description here and follow its instructions. This should also include a test case. Once you've done this and Yetus is happy I'll take another look. I'm not familiar with why newer Fuse impls. would clear those flags, so any reference to that information would be helpful as well.

@shanrui

shanrui commented Jun 12, 2026

Copy link
Copy Markdown
Author

@ajfabbri Thanks for the feedback.

There is a related historical Jira, HDFS-2551. While the root cause is different, the observed behavior is conceptually similar: if data is not properly flushed (especially when hdfs flush() not hdfs hflush() is invoked), HDFS cannot guarantee that newly written data will be immediately visible to readers. In this case, skipping hdfsHFlush() in dfs_flush() can lead to the same symptom: a reader opened after the write may observe an empty file or stale data until the writer closes the file.

Regarding fi->flags, I found that as early as FUSE 2.4 the documentation did not guarantee that the original open flags would be reliably preserved across all callback invocations(https://github.com/libfuse/libfuse/blob/fuse_2_4_0/include/fuse_common.h#L36). Because of this, using fi->flags inside flush() to determine whether the file was opened for writing may not be reliable. In my environment, fi->flags was observed to be zero in dfs_flush(), which caused hdfsHFlush() to be skipped entirely.

I'm working on creating a Jira and adding a test case as suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants