Repository navigation
[4.2-dev] fix(fileservice): prevent duplicate range fan-out - #26842
Merged
mergify[bot] merged 2 commits intoAug 9, 2026
Merged
mergify[bot] merged 2 commits into
mergify[bot] merged 2 commits into
Conversation
) ### Root cause When a full-object disk-cache fill is still running, followers wait only 200ms and then use `readMinimalRange`. For a multi-column `IOVector`, that function reads one continuous `[min offset, max end]` envelope rather than the logical entry bytes. Sparse columns can therefore turn a few MiB of requested data into a 100+ MiB S3 GET per follower. Under high concurrency this bypasses the existing I/O merge, saturates the 100-connection HTTP pool, and amplifies heap/network pressure until transactions and client connections time out. ### Fix - Compute the logical bytes, span bytes, and amplification of unfinished entries before bypassing a full-object merge. - Preserve the existing 200ms fallback for single entries, small spans, and low-amplification ranges. - Record on each active merger generation whether its actual leader can publish a reusable full-object disk-cache artifact; followers use the capability of the exact generation they joined, rather than inferring it from their own vector. - When a cache-producing full-object generation is active and the fallback span is larger than 8MiB with amplification above 8x, wait for that generation instead of issuing another broad range GET. - Bound this second-stage wait with both the caller context and the existing one-minute I/O merge limit. - If the leader is not cache-producing, or the local limit expires, read unfinished entries as sequential exact ranges instead of one large sparse envelope. The timeout path rechecks caches once first. - Record the long wait in existing S3FS/IOMerger timing metrics and slow-event details. ### Safety boundaries - No change to on-disk/wire formats, configuration defaults, cache-hit paths, or reads without merge contention. - No new goroutine, persistent per-object state, queue, semaphore, or retry loop. - The cache-producer capability is immutable and scoped to one merger generation. Completion checks and second-stage waits remain bound to that same generation even if a new leader starts for the key. - `WriterForRead` and `ReadCloserForRead` leaders do not extend follower waits because they cannot publish the shared full-file cache result. - Leader completion, caller cancellation, and the local wait limit are independent terminal events. - A wait timeout only changes the current follower's local read mode. It does not cancel, delete, or otherwise mutate the active merge generation. - Fallback is sequential and fetches each unfinished entry's exact range, preserving follower progress without recreating the large envelope. ### Regression evidence Three deterministic regressions cover the expensive sparse branch: - On clean `base/main`, a held full-object merge causes the sparse follower to issue one extra broad ObjectStorage read before its caller deadline (`expected 0, actual 1`). The patch keeps the remote read count at zero until cancellation. - On the first PR head, a no-deadline caller remains blocked behind a held cache-producing leader and fails a one-second progress guard. The final patch reaches the bounded fallback and issues exactly `[0,1)` and `[9MiB,9MiB+1)`, never the 9MiB envelope. - On the previous PR head, a real `WriterForRead` leader blocked in its writer causes an ordinary sparse follower to lose its deadline without issuing a read. The final patch identifies that generation as non-cache-producing and performs exactly the two requested range reads after the original short wait. Verified on final commit: - `GOWORK=off go build -mod=readonly ./pkg/fileservice` - `GOWORK=off go vet -mod=readonly ./pkg/fileservice` - `mo-cgo-test -count=1 -timeout=300s ./pkg/fileservice` - Relevant merger and sparse-range tests with `-race -count=100`, including generation ownership, cancellation, no-deadline fallback, non-cache-producing leaders, and historical cheap-range fallback - Full `pkg/fileservice` package with `-race -count=1` Approved by: @XuPeng-SH (cherry picked from commit 47c8302)
(cherry picked from commit ef94b08)
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
approved these changes
Aug 9, 2026
Contributor
Merge Queue Status
This pull request spent 15 seconds in the queue, including 1 second running CI. Required conditions to merge
|
This branch was previously deployed
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 type of PR is this?
Which issue(s) this PR fixes:
issue #25129
issue #26172
What this PR does / why we need it:
Backport the complete FileService range fan-out fix to
4.2-dev.4.2-devcontains the range-bypass and 200 ms fallback introduced by #24759and #24871, but does not contain #26758. Therefore backporting only the
single-entry follow-up from #26834 would leave the multi-entry sparse-range
fan-out unchanged. This PR applies both fixes in dependency order:
cache-producing merge generation.
full-object generation exceeds its short wait.
The normal cache-hit and uncontended read paths are unchanged. All waits remain
caller-cancelable and bounded. Merge generations have no background goroutine
or persistent queue and are deleted on leader completion. Followers recheck
cache publication before falling back to a bounded exact read.
Validation on the
4.2-devbase (4066fffaf7):-count=3-race(20or100repetitions)pkg/fileservicetestpkg/fileservicerace testgo buildandgo vetforpkg/fileserviceBackported commits retain
-xprovenance for #26758 and #26834.