Repository navigation
[Fix] Isolate FileReaderManager reader I/O with per-file locks - #18788
Merged
JackieTien97 merged 9 commits intoOct 9, 2026
Merged
JackieTien97 merged 9 commits into
JackieTien97 merged 9 commits into
Conversation
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.
Description
A slow reader open or close currently holds the FileReaderManager monitor, stalling unrelated files. Reference registration can also hold a DataRegion read lock while waiting for reader I/O, delaying writes and new queries in that region. This change serializes reader I/O per file and keeps reference registration in a short registry critical section, so it does not wait for an opening or closing reader.
Reader lifecycle and locking
Reference ownership
Remove failed registrations from fragment release sets to prevent a second read-lock release. The lightweight fragment context records the closed/unclosed state at registration and rolls back partial initialization, so sealing a file cannot redirect its release to another query's slot. TsFileLock preserves read/write exclusion when a waiting thread is interrupted and restores interrupt status only after acquisition.
Deleted-file releases and initialization rollback run after releasing the DataRegion read lock. Initialization-local pending references retain their file locks until cleanup, including references from a batch that fails before publishing its lease. Cleanup attempts every queued release and preserves the original initialization exception. Region scans also release the region lock when acquisition consumes the remaining time slice.
Validation
Validated on the PR branch with Amazon Corretto 17.0.5, Maven 3.9.9, and cached TsFile
2.4.1-260915-SNAPSHOTartifacts. Maven ran offline with Develocity disabled; builds, test data, and temporary files stayed on the external test volume.mvn clean test-compile -DskipTests: 53 modules successful.mvn clean test-compile -P with-zh-locale -DskipTests: 53 modules successful.mvn spotless:apply -pl iotdb-core/datanode, full-reactor formatting checks in both compile runs, andgit diff --check: passed.Distributed-cluster and object-storage end-to-end tests were not run.