Skip to content

HDDS-15424. Fix Concurrent positional read - #11102

Open
taklwu wants to merge 6 commits into
apache:masterfrom
taklwu:HDDS-15424
Open

HDDS-15424. Fix Concurrent positional read#11102
taklwu wants to merge 6 commits into
apache:masterfrom
taklwu:HDDS-15424

Conversation

@taklwu

@taklwu taklwu commented Aug 24, 2026

Copy link
Copy Markdown
  • introduce stateless pread for major input streams
  • introduced ozone.fs.synchronize.positioned.reads.enabled
  • use cursor editor to assist this change.

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 copyRange without touching shared cursor / position and avoid race condition.

in addition, introduce a new/fallback opt-in feature ozone.fs.synchronize.positioned.reads.enabled for concurrently positional read for when stateless pread is not implemented. e.g. any child class of ExtendedInputStream without implementing the readFully.

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 synchronized block 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?

  1. provided unit tests
  2. tested again on a HBase's Regionserver with this change, and we don't see the checksum error as reported, but I found the max RPS drop from 11k to 6.8k, so making this feature as default optional

Copilot AI lite review requested due to automatic review settings August 24, 2026 18:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.enabled to optionally synchronize positioned reads in OzoneFSInputStream.
  • 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.

@taklwu taklwu changed the title HDDS-15424. Non-Stream read failed positional read checksum intermitt… HDDS-15424. Fix Concurrent positional read Aug 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.

@peterxcli
peterxcli self-requested a review August 24, 2026 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants