Skip to content

fix(fileservice): coalesce duplicate single-range fallbacks - #26834

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
LeftHandCold:fix/issue-25129-single-range-merge
Aug 9, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
LeftHandCold:fix/issue-25129-single-range-merge

Conversation

@LeftHandCold

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #26172

Follow-up to #26758.

What this PR does / why we need it:

Root cause

#26758 prevents a stalled full-object cache fill from turning sparse multi-entry reads into large amplified S3 ranges. It intentionally preserves the 200ms fallback for a single bounded entry.

That remaining path bypasses the I/O merger. When many requests need the same entry while the full-object fill is still running, every follower starts the same exact S3 range GET after 200ms. A small hot range can therefore fan out across the object-storage connection pool and increase network, heap, and query latency pressure.

Fix

  • After the existing 200ms full-object wait expires, create a second merger generation keyed by the exact single-entry range.
  • Admit this merge only when the leader can publish a reusable memory-cache or per-entry disk-cache result.
  • Bind followers to the exact generation and wait at most the existing one-minute I/O limit, also respecting the caller context.
  • Recheck caches after leader completion. If publication fails or the wait expires, continue with the existing exact-range fallback without rejoining either merge generation.
  • Keep leader completion ordered after deferred cache updates, so followers cannot wake before the reusable result is published.

Safety boundaries

  • Cache hits, uncontended reads, multi-entry reads, stream reads, and no-cache-write reads are unchanged.
  • Different ranges use different merge keys and proceed independently.
  • No goroutine, queue, retry loop, wire format, disk format, or configuration is added.
  • Cancellation and the existing local I/O wait limit remain terminal bounds.
  • Cache admission failure remains a normal cache miss and falls back to one exact range read.

Tests

  • A deterministic blocked-storage test starts 16 same-range followers and proves they do not issue duplicate object-storage reads, honor caller cancellation, and reuse the leader's published cache result.
  • A second deterministic test proves different exact ranges do not block each other.
  • Focused tests passed with -race -count=20.
  • Full pkg/fileservice tests and full package race tests passed.
  • go build, go vet, and git diff --check passed.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Aug 9, 2026
@mergify mergify Bot added kind/bug Something isn't working kind/enhancement labels Aug 9, 2026
mergify Bot pushed a commit that referenced this pull request Aug 9, 2026
Backport the complete FileService range fan-out fix to `4.2-dev`.

`4.2-dev` contains the range-bypass and 200 ms fallback introduced by #24759
and #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:

1. #26758: avoid wide sparse fallback reads and bind waiters to the exact
cache-producing merge generation.
2. #26834: coalesce duplicate single-entry exact-range fallbacks after the
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-dev` base (`4066fffaf7`):

- focused FileService regression set, `-count=3`
- six concurrency/lifecycle tests under `-race` (`20` or `100` repetitions)
- full `pkg/fileservice` test
- full `pkg/fileservice` race test
- `go build` and `go vet` for `pkg/fileservice`

Backported commits retain `-x` provenance for #26758 and #26834.

Approved by: @XuPeng-SH

@XuPeng-SH XuPeng-SH 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.

Deep review completed. No blocking correctness, concurrency, lifecycle, or performance findings. Verified cache publication precedes generation completion; bounded exact-range fallback respects cancellation and does not rejoin a timed-out generation. Local pkg/fileservice build, vet, focused tests, full package tests, and race checks passed.

@mergify mergify Bot added the queued label Aug 9, 2026
@mergify

mergify Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-09 14:03 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-08-09 14:11 UTC · at 867a009db2bb4d85fc1739a49e4910c40b413a05

This pull request spent 8 minutes 26 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]

Reason

Pull request #26834 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Failing checks:

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit 415724f into matrixorigin:main Aug 9, 2026
23 of 24 checks passed
@mergify mergify Bot added dequeued and removed queued labels Aug 9, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…igin#26834)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#26172

Follow-up to matrixorigin#26758.

## What this PR does / why we need it:

### Root cause

matrixorigin#26758 prevents a stalled full-object cache fill from turning sparse
multi-entry reads into large amplified S3 ranges. It intentionally
preserves the 200ms fallback for a single bounded entry.

That remaining path bypasses the I/O merger. When many requests need the
same entry while the full-object fill is still running, every follower
starts the same exact S3 range GET after 200ms. A small hot range can
therefore fan out across the object-storage connection pool and increase
network, heap, and query latency pressure.

### Fix

- After the existing 200ms full-object wait expires, create a second
merger generation keyed by the exact single-entry range.
- Admit this merge only when the leader can publish a reusable
memory-cache or per-entry disk-cache result.
- Bind followers to the exact generation and wait at most the existing
one-minute I/O limit, also respecting the caller context.
- Recheck caches after leader completion. If publication fails or the
wait expires, continue with the existing exact-range fallback without
rejoining either merge generation.
- Keep leader completion ordered after deferred cache updates, so
followers cannot wake before the reusable result is published.

### Safety boundaries

- Cache hits, uncontended reads, multi-entry reads, stream reads, and
no-cache-write reads are unchanged.
- Different ranges use different merge keys and proceed independently.
- No goroutine, queue, retry loop, wire format, disk format, or
configuration is added.
- Cancellation and the existing local I/O wait limit remain terminal
bounds.
- Cache admission failure remains a normal cache miss and falls back to
one exact range read.

### Tests

- A deterministic blocked-storage test starts 16 same-range followers
and proves they do not issue duplicate object-storage reads, honor
caller cancellation, and reuse the leader's published cache result.
- A second deterministic test proves different exact ranges do not block
each other.
- Focused tests passed with `-race -count=20`.
- Full `pkg/fileservice` tests and full package race tests passed.
- `go build`, `go vet`, and `git diff --check` passed.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…igin#26834)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#26172

Follow-up to matrixorigin#26758.

## What this PR does / why we need it:

### Root cause

matrixorigin#26758 prevents a stalled full-object cache fill from turning sparse
multi-entry reads into large amplified S3 ranges. It intentionally
preserves the 200ms fallback for a single bounded entry.

That remaining path bypasses the I/O merger. When many requests need the
same entry while the full-object fill is still running, every follower
starts the same exact S3 range GET after 200ms. A small hot range can
therefore fan out across the object-storage connection pool and increase
network, heap, and query latency pressure.

### Fix

- After the existing 200ms full-object wait expires, create a second
merger generation keyed by the exact single-entry range.
- Admit this merge only when the leader can publish a reusable
memory-cache or per-entry disk-cache result.
- Bind followers to the exact generation and wait at most the existing
one-minute I/O limit, also respecting the caller context.
- Recheck caches after leader completion. If publication fails or the
wait expires, continue with the existing exact-range fallback without
rejoining either merge generation.
- Keep leader completion ordered after deferred cache updates, so
followers cannot wake before the reusable result is published.

### Safety boundaries

- Cache hits, uncontended reads, multi-entry reads, stream reads, and
no-cache-write reads are unchanged.
- Different ranges use different merge keys and proceed independently.
- No goroutine, queue, retry loop, wire format, disk format, or
configuration is added.
- Cancellation and the existing local I/O wait limit remain terminal
bounds.
- Cache admission failure remains a normal cache miss and falls back to
one exact range read.

### Tests

- A deterministic blocked-storage test starts 16 same-range followers
and proves they do not issue duplicate object-storage reads, honor
caller cancellation, and reuse the leader's published cache result.
- A second deterministic test proves different exact ranges do not block
each other.
- Focused tests passed with `-race -count=20`.
- Full `pkg/fileservice` tests and full package race tests passed.
- `go build`, `go vet`, and `git diff --check` passed.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…igin#26834)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#26172

Follow-up to matrixorigin#26758.

## What this PR does / why we need it:

### Root cause

matrixorigin#26758 prevents a stalled full-object cache fill from turning sparse
multi-entry reads into large amplified S3 ranges. It intentionally
preserves the 200ms fallback for a single bounded entry.

That remaining path bypasses the I/O merger. When many requests need the
same entry while the full-object fill is still running, every follower
starts the same exact S3 range GET after 200ms. A small hot range can
therefore fan out across the object-storage connection pool and increase
network, heap, and query latency pressure.

### Fix

- After the existing 200ms full-object wait expires, create a second
merger generation keyed by the exact single-entry range.
- Admit this merge only when the leader can publish a reusable
memory-cache or per-entry disk-cache result.
- Bind followers to the exact generation and wait at most the existing
one-minute I/O limit, also respecting the caller context.
- Recheck caches after leader completion. If publication fails or the
wait expires, continue with the existing exact-range fallback without
rejoining either merge generation.
- Keep leader completion ordered after deferred cache updates, so
followers cannot wake before the reusable result is published.

### Safety boundaries

- Cache hits, uncontended reads, multi-entry reads, stream reads, and
no-cache-write reads are unchanged.
- Different ranges use different merge keys and proceed independently.
- No goroutine, queue, retry loop, wire format, disk format, or
configuration is added.
- Cancellation and the existing local I/O wait limit remain terminal
bounds.
- Cache admission failure remains a normal cache miss and falls back to
one exact range read.

### Tests

- A deterministic blocked-storage test starts 16 same-range followers
and proves they do not issue duplicate object-storage reads, honor
caller cancellation, and reuse the leader's published cache result.
- A second deterministic test proves different exact ranges do not block
each other.
- Focused tests passed with `-race -count=20`.
- Full `pkg/fileservice` tests and full package race tests passed.
- `go build`, `go vet`, and `git diff --check` passed.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch was previously deployed

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

Labels

kind/bug Something isn't working kind/enhancement size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants