HDDS-15424. Fix Concurrent positional read - #11102
Open
taklwu wants to merge 6 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces an opt-in mechanism to make positioned reads (pread) thread-safe in OzoneFS by serializing the seek-read-restore sequence inside OzoneFSInputStream, addressing intermittent checksum failures when multiple threads reuse the same input stream.
Changes:
- Add
ozone.fs.synchronize.positioned.reads.enabledto optionally synchronize positioned reads inOzoneFSInputStream. - Plumb the new flag through the OzoneFS implementations so the created FS input streams honor the configuration.
- Add a unit test that exercises concurrent positioned reads with the flag enabled/disabled.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/RootedOzoneFileSystem.java | Passes the new positioned-read synchronization flag when constructing the FS input stream wrapper. |
| hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzoneFileSystem.java | Passes the new positioned-read synchronization flag when constructing the FS input stream wrapper. |
| hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/RootedOzoneFileSystem.java | Same flag plumbing for the Hadoop3 variant. |
| hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/OzoneFileSystem.java | Same flag plumbing for the Hadoop3 variant. |
| hadoop-ozone/ozonefs-common/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFSInputStream.java | Adds concurrent positioned-read coverage to validate the opt-in synchronization behavior. |
| hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/OzoneFSInputStream.java | Implements optional serialization of positioned reads via an internal lock. |
| hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/CapableOzoneFSInputStream.java | Extends constructors to propagate the new positioned-read synchronization option. |
| hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java | Reads the new config key and uses it when creating OzoneFSInputStream. |
| hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java | Reads the new config key and uses it when creating OzoneFSInputStream. |
| hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/OzoneConfigKeys.java | Defines the new configuration key and default value. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
peterxcli
self-requested a review
August 24, 2026 23:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Fix Non-Stream read failed positional read checksum intermittently during concurrently access by multi-threads.
Please describe your PR in detail:
Fixing the concurrent positional read by introducing stateless pread for major input streams (BlockInputStream, ChunkInputStream, MultiPartInputStream) as the default pread method, such that the read could be getting the range / chunkinfo via readChunk (additional RPC) and use
copyRangewithout touching shared cursor / position and avoid race condition.in addition, introduce a new/fallback opt-in feature
ozone.fs.synchronize.positioned.reads.enabledfor concurrently positional read for when stateless pread is not implemented. e.g. any child class of ExtendedInputStream without implementing thereadFully.The problem without thread-safe inputstream, checksum may fail because the offset has moved from the current position.
note that hadoop's FSInputStream does have this
synchronizedblock and make sure the input stream is thread-safe. Also we're learning from DFSInputStream's getBlockRange and have this logic as an additional RPC that used by readChunk and copyRange.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15424
How was this patch tested?