Skip to content

fix(fileservice): coalesce same-key warm disk-cache column fills - #28918

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
LeftHandCold:fix/fileservice-column-fill-28898
Sep 15, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
LeftHandCold:fix/fileservice-column-fill-28898

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:

Fixes #28898: the reproduced main-branch same-key disk-read/decode amplification mechanism.

What this PR does / why we need it:

Problem

After concurrent MemCache misses, readers of the same immutable column can each read its DiskCache extent before any reader publishes decoded data. Existing scoped decode sharing starts after disk I/O and has a bounded admission quota. When that quota is exhausted, duplicate decoded allocations can evict useful cache entries before MemCache insertion detects the duplicate key.

This causes avoidable read/decode amplification even when the working set fits MemCache. It is distinct from the existing cold-object S3 IOMerger path.

Narrow change

  • Coordinate an already DecodeSharing-marked immutable column at the S3FS.Read boundary, before disk I/O. Keep the existing one-selected-column eligibility and policy checks.
  • Enter only when DiskCache's existing index reports the full file present, or the exact range for a single-entry request. The index is a hint, not a substitute for the actual read.
  • Recheck MemCache before I/O. Successful disk-fill leaders notify followers only after deferred MemCache publication; followers then read through the normal cache API.
  • Do not start a new fill when pending memory reservations or an active memory-pressure target make publication unsuitable. This read-only hint does not reserve or evict anything, and existing same-key fills can still accept followers.
  • Leave coordination before remote-cache/S3 work when the disk read is incomplete. Cold/unindexed paths do not acquire a fill ticket.

Lifecycle and bounds

  • Reuse the existing FileService decoded-read registry and close/read lifetime. The new records hold notification metadata only, not decoded buffers.
  • Limit live fill generations to 64 and participants per generation to 128. Detached generations remain charged until their final participant releases them.
  • At most one added fill wait per Read, bounded by one second and interruptible by cancellation or service close. Timeout/admission bypass resumes the existing read path without rejoining the fill.
  • Completion is a notification, not a shared error result: a failed or canceled leader does not turn a healthy follower into a failed read.
  • No new goroutines, global disk throttle, cache-budget/eviction changes, SQL/planner changes, routing changes, configuration, production hooks, or persistent-format changes.

Tests and validation

The committed UTs cover same-key disk-fill reuse with available and saturated decode-sharing admission, publication-before-notification, key isolation, participant/generation limits, cancellation, timeout, close, stale-generation release, memory admission, and cold-path bypass. They also retain the existing independent fallback coverage.

Validation on the final file contents, based on upstream main 2ea4ec2e6ef4b20321a235ef416228506813e39b:

Validation Result
Full FileService package, normal PASS, 15.592s
Full FileService package, race PASS, 24.557s
Focused disk-fill/shared-decode tests, race x30 PASS, 13.278s
Linux FileService integration, four CPUs, x5 PASS
Same Linux integration, race PASS
go vet ./pkg/fileservice, formatting, diff checks PASS

The separate Linux integration uses real FileService, DiskCache, MemCache, native allocation and LZ4 with the local disk-backed object-storage endpoint. Its baseline is bb358ea76aeb44a6eed5079616e7e75ba35e75b9; the candidate adds only the two production files. FileService/ObjectIO production code and dependency versions were checked for equivalence between that baseline and the main base above. The external diagnostic harness is not added to this PR.

For eight overlapping requests for one missing immutable column, with seven other columns warm and decode sharing saturated:

Counter Baseline Candidate
Disk reads 8 1
Conversions 8 1
Logical disk bytes 295,224 36,903
Retained MemCache data after the wave 1 MiB 8 MiB

Payload equality and reservation/registry cleanup are checked. The cold control remains one source GET, zero disk hits and one conversion. Different-key, memory-hit, single-reader and non-admitting controls are also exercised.

Adjacent four-core benchmark samples on the final candidate did not reproduce a sustained regression in different-key or memory-ineligible overlapping reads. Samples contain host noise and are not a universal no-regression or speedup claim; the metadata coordination has a small allocation cost.

Reproducible owning-package checks, with the repository-supported Go/CGo environment:

GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/fileservice
GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/fileservice
GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=30 -timeout=600s \
  -run '^(TestSharedDecodeFill.*|TestS3FSSharedDecodeDiskFill.*|TestS3FSSharedDecodeDiskHits)$' \
  ./pkg/fileservice

Scope and evidence limits

This fixes the reproduced mechanism with bounded coordination; it does not guarantee that every same-key miss will coalesce under timeout, cache eviction or admission pressure. Full IVF-10M SQL latency recovery and the fraction of nightly multi-TB traffic attributable to this mechanism have not been validated. No external COS test, cluster rollout or 4.2 backport is claimed.

Self-review covered publication ordering, ownership, all ticket terminal paths, cancellation/close, stale generations and resource bounds. No unresolved blocker was found in this scope.

Coordinate opted-in immutable column fills before disk IO with bounded notification-only generations. Publish through the existing memory-cache path and retain cold-read and admission fallbacks.

Add focused lifecycle, cancellation, close, admission and disk-read regression coverage for matrixorigin#28898.
@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 →

@LeftHandCold LeftHandCold left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Review of 1de99ef26646175668fda0488aa066bba4c61b36 against fresh main / merge-base 2ea4ec2e6ef4b20321a235ef416228506813e39b: no blocking finding identified; code-review recommendation is APPROVE.

Read all changed hunks in the two production files and test file, and traced the affected S3FS.Read → DiskCache/IOEntry → MemCache publication and ObjectIO marked-entry consumers. This is a focused fix for #28898's reproduced warm-disk amplification, not a general singleflight guarantee or a 4.2 fix.

Key checks:

  • Successful disk completion returns through the deferred MemCache update before fill completion wakes followers. Followers reacquire data through the ordinary cache API; notification records do not own decoded buffers.
  • An incomplete disk read finishes its fill before remote-cache/S3 fallback. The existing cold IOMerger path is preserved. Failed/cancelled leaders do not publish an error as the fill result.
  • Admission preserves the existing one-selected-entry, immutable codec/key and policy restrictions. Disk-index presence and memory headroom are hints, not correctness assumptions; eviction/admission races can reduce coalescing but do not make cache misses incorrect.
  • Registry, cache-capacity and disk-index locks are not nested across the new wait or data I/O. Timeout does not rejoin the fill.

Unhappy-path closure:

Audit Result
Q1 ownership Read-scoped ticket completion/release is idempotent; decoded buffers retain their existing ownership. Deferred fill release precedes the guarded read's final retirement.
Q2 waits Added follower wait has a one-second timer, context cancellation and service-close wakeup. Close does not wait for the active disk operation under the registry lock.
Q3 bounds 64 live fill generations / 128 participants each; detached generations remain charged until final release. Pointer identity prevents stale-generation deletion.

Evidence: reused the PR's author-reported final-content FileService normal/race package passes, focused race repetitions, Linux integration and control/benchmark evidence. The source base stated there matches this review's base. These were not re-run by this reviewer; no additional heavy build, UT campaign, or live cluster was started. Local Go 1.26.4 formatting and diff checks passed; isolated worktree is clean. GitHub build/UT checks are still pending/in progress and are not represented as green.

Remaining scope limits are correctly stated: no full IVF-10M SQL latency recovery result, no attribution of all nightly multi-TB reads to this mechanism, and no 4.2 backport. Those are not new blockers for this narrowly tested mechanism fix.

The authenticated account is the PR author, so GitHub prohibits a formal self-APPROVE. This COMMENT records the no-blocker recommendation; it does not change the review state to APPROVED.

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

GPT-6 medium deep review at exact head 1de99ef.\n\nP2 — required per-test race-stress evidence is missing for the new shared-state concurrency tests, including publication ordering, failure isolation, and close in pkg/fileservice/shared_decode_test.go. The current evidence is a combined-regex race -count=30 report plus a CI package race run; it does not provide individually selected exact-test measurements and adaptive repetitions.\n\nPlease provide exact-head terminal output for each affected test's initial race measurement and separate adaptive repetition run, with test selection and execution mode recorded. This is a validation-evidence blocker, not a demonstrated runtime race.

@LeftHandCold

Copy link
Copy Markdown
Collaborator Author

Follow-up: individual adaptive race validation

@XuPeng-SH Thanks. I agree that the previous combined-regex -race -count=30 record did not satisfy the repository's individual-test adaptive stress protocol. This review identifies a validation-evidence gap, not a demonstrated runtime race.

I have now completed the missing validation on unchanged PR head 1de99ef26646175668fda0488aa066bba4c61b36. No production code, test code, hooks, timeout constants, or assertions were changed to obtain these results.

Selection and execution mode

  • Selected all eight new top-level tests, the changed disk-hit regression test, and five directly affected existing read/failure/close tests. The two sequential eligibility tests are included for a complete inventory of the added cases.
  • Host: darwin/arm64, go version go1.26.4 darwin/arm64, native repository CGo wrapper, GOMAXPROCS=4, GOWORK=off, GOFLAGS="", LC_ALL=C, LANG=C. These are local focused race tests, not a new remote SQL/performance run.
  • Each exact anchored test was first measured in its own invocation with -race -json -count=1. T is the top-level test's terminal JSON Elapsed, excluding build/package/process overhead.
  • Applied N = clamp(floor(30 / T), 1, 100); zero-resolution measurements use 100. Then ran a separate invocation for that exact test with -race -json -count=N -timeout=120s -failfast. All repetitions of a test stay in that invocation, not a shell loop of fresh processes.
  • Audited raw JSON independently: exact selection nonempty; no unexpected test selection; every expected top-level and child run has its corresponding PASS; no skipped/failed tests or data-race reports; package terminal PASS and process exit 0 for every invocation.
  • 14 initial measurements + 1400 top-level stress executions passed (also 3100 child PASS events in the stress runs). All 28 invocations terminated and were reaped. Before/after Git HEAD, clean worktree, source hashes, wrapper, dependencies and native-library hashes match.

Per-test results

The repeat elapsed column is terminal package elapsed for that one exact-test invocation. It is not the initial T used to choose N.

Exact test Initial T (s) N Repeat top-level run/pass Repeat elapsed (s) Initial/repeat exits
TestSharedDecodeFillAdmissionAndKeyIsolation 0.00 100 100/100 1.237 0 / 0
TestSharedDecodeFillWaitCancellationAndClose 0.00 100 100/100 1.288 0 / 0
TestS3FSSharedDecodeDiskFillEligibility 0.02 100 100/100 2.054 0 / 0
TestS3FSSharedDecodeDiskFillMemoryEligibility 0.05 100 100/100 6.976 0 / 0
TestS3FSSharedDecodeDiskFill 0.04 100 100/100 7.693 0 / 0
TestS3FSSharedDecodeDiskFillFailureIsolation 0.06 100 100/100 11.196 0 / 0
TestS3FSSharedDecodeDiskFillClose 0.02 100 100/100 3.977 0 / 0
TestS3FSSharedDecodeDiskFillSkipsColdPaths 0.07 100 100/100 10.767 0 / 0
TestS3FSSharedDecodeDiskHits 0.02 100 100/100 4.165 0 / 0
TestS3FSSelectedDecodeReadPaths 0.05 100 100/100 4.313 0 / 0
TestS3FSSelectedDecodeFailureIsolation 0.03 100 100/100 2.476 0 / 0
TestS3FSSelectedDecodeCloseDuringSibling 0.02 100 100/100 2.645 0 / 0
TestS3FSSharedDecodeCloseDefersCacheRetirement 0.02 100 100/100 1.761 0 / 0
TestS3FSSharedDecodeCloseDuringCacheUpdate 0.02 100 100/100 2.518 0 / 0

Exact commands and terminal output

The following blocks retain the actual terminal JSON lines. For repetition runs, the last top-level PASS and terminal package PASS are shown; the full raw streams were checked for the exact run/pass counts above. SHA-256 identifies each complete stdout stream. Initial and repetition commands were executed separately, in sequence.

TestSharedDecodeFillAdmissionAndKeyIsolation

Initial measurement:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=1 -timeout=120s -run '^TestSharedDecodeFillAdmissionAndKeyIsolation$' ./pkg/fileservice
{"Time":"2026-09-15T18:50:27.395125+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestSharedDecodeFillAdmissionAndKeyIsolation","Elapsed":0}
{"Time":"2026-09-15T18:50:28.401767+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":1.087}

Initial exit: 0.

Adaptive repetition:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=100 -timeout=120s -run '^TestSharedDecodeFillAdmissionAndKeyIsolation$' -failfast ./pkg/fileservice
{"Time":"2026-09-15T18:50:32.357723+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestSharedDecodeFillAdmissionAndKeyIsolation","Elapsed":0}
{"Time":"2026-09-15T18:50:33.367504+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":1.237}

Repeat exit: 0; exact top-level run/pass: 100/100; no failures/skips/race reports.

Complete stdout SHA-256:

measurement 2c2793acee75672b6dc01a381f0222ddabb41f735cb70e562496a2208cbddf3a
stress      4c5c8c71c60864828fc21f4e4781964dd259bf5c31e37e6d5859156f1af946f4
TestSharedDecodeFillWaitCancellationAndClose

Initial measurement:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=1 -timeout=120s -run '^TestSharedDecodeFillWaitCancellationAndClose$' ./pkg/fileservice
{"Time":"2026-09-15T18:50:35.075186+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestSharedDecodeFillWaitCancellationAndClose","Elapsed":0}
{"Time":"2026-09-15T18:50:36.086744+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":1.089}

Initial exit: 0.

Adaptive repetition:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=100 -timeout=120s -run '^TestSharedDecodeFillWaitCancellationAndClose$' -failfast ./pkg/fileservice
{"Time":"2026-09-15T18:50:37.932289+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestSharedDecodeFillWaitCancellationAndClose","Elapsed":0}
{"Time":"2026-09-15T18:50:38.943847+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":1.288}

Repeat exit: 0; exact top-level run/pass: 100/100; no failures/skips/race reports.

Complete stdout SHA-256:

measurement f7440147e83e20e2ec225a6b15b22552c62491574fa498bca4289590f03c49ba
stress      dde918b851c5462d907bcab20900e26588ee1d099da88b484a13d2a4872a47bd
TestS3FSSharedDecodeDiskFillEligibility

Initial measurement:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=1 -timeout=120s -run '^TestS3FSSharedDecodeDiskFillEligibility$' ./pkg/fileservice
{"Time":"2026-09-15T18:50:40.791762+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSharedDecodeDiskFillEligibility","Elapsed":0.02}
{"Time":"2026-09-15T18:50:41.798075+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":1.105}

Initial exit: 0.

Adaptive repetition:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=100 -timeout=120s -run '^TestS3FSSharedDecodeDiskFillEligibility$' -failfast ./pkg/fileservice
{"Time":"2026-09-15T18:50:44.468968+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSharedDecodeDiskFillEligibility","Elapsed":0.01}
{"Time":"2026-09-15T18:50:45.486351+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":2.054}

Repeat exit: 0; exact top-level run/pass: 100/100; no failures/skips/race reports.

Complete stdout SHA-256:

measurement 604d1d5f87698dbf93f114b69e3e423cd17db126d5d8da59603afb6e45fb7619
stress      237de20152d6ba58d4046b0b5a4c563b53b5e97e93a07a067100dfd232d6056e
TestS3FSSharedDecodeDiskFillMemoryEligibility

Initial measurement:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=1 -timeout=120s -run '^TestS3FSSharedDecodeDiskFillMemoryEligibility$' ./pkg/fileservice
{"Time":"2026-09-15T18:50:47.292063+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSharedDecodeDiskFillMemoryEligibility","Elapsed":0.05}
{"Time":"2026-09-15T18:50:48.32115+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":1.155}

Initial exit: 0.

Adaptive repetition:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=100 -timeout=120s -run '^TestS3FSSharedDecodeDiskFillMemoryEligibility$' -failfast ./pkg/fileservice
{"Time":"2026-09-15T18:50:55.855362+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSharedDecodeDiskFillMemoryEligibility","Elapsed":0.05}
{"Time":"2026-09-15T18:50:56.914669+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":6.976}

Repeat exit: 0; exact top-level run/pass: 100/100; no failures/skips/race reports.

Complete stdout SHA-256:

measurement 6df1827823818ffe1c0165949ca5da4bd5179cecb5b5104ff712d65c37d3d3f5
stress      e7d22029deba6f2e3c9c9404ba214d8372861234e1865084d2bf81f2b8bab37f
TestS3FSSharedDecodeDiskFill

Initial measurement:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=1 -timeout=120s -run '^TestS3FSSharedDecodeDiskFill$' ./pkg/fileservice
{"Time":"2026-09-15T18:51:00.108656+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSharedDecodeDiskFill","Elapsed":0.04}
{"Time":"2026-09-15T18:51:01.126346+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":1.134}

Initial exit: 0.

Adaptive repetition:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=100 -timeout=120s -run '^TestS3FSSharedDecodeDiskFill$' -failfast ./pkg/fileservice
{"Time":"2026-09-15T18:51:09.254986+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSharedDecodeDiskFill","Elapsed":0.07}
{"Time":"2026-09-15T18:51:10.310854+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":7.693}

Repeat exit: 0; exact top-level run/pass: 100/100; no failures/skips/race reports.

Complete stdout SHA-256:

measurement 5888b34de5263bc32a1f4d1f478aa3cdac9695c8778b6c69cd6dc9f45cb4013b
stress      c530a72716b10c50dd8e85e92b6c0b5eb4cf858f91f900f66eda9010196938f9
TestS3FSSharedDecodeDiskFillFailureIsolation

Initial measurement:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=1 -timeout=120s -run '^TestS3FSSharedDecodeDiskFillFailureIsolation$' ./pkg/fileservice
{"Time":"2026-09-15T18:51:13.290165+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSharedDecodeDiskFillFailureIsolation","Elapsed":0.06}
{"Time":"2026-09-15T18:51:14.303398+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":1.144}

Initial exit: 0.

Adaptive repetition:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=100 -timeout=120s -run '^TestS3FSSharedDecodeDiskFillFailureIsolation$' -failfast ./pkg/fileservice
{"Time":"2026-09-15T18:51:25.90588+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSharedDecodeDiskFillFailureIsolation","Elapsed":0.1}
{"Time":"2026-09-15T18:51:26.993692+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":11.196}

Repeat exit: 0; exact top-level run/pass: 100/100; no failures/skips/race reports.

Complete stdout SHA-256:

measurement 6a7bed71283ffa5f89872418e3d4f801d133f229ff67a01e32b7e583fad0d8da
stress      85260e2fda7c26ee4f1feabb5b6d0bb9931eb753101839238c86e1c4dd721a0e
TestS3FSSharedDecodeDiskFillClose

Initial measurement:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=1 -timeout=120s -run '^TestS3FSSharedDecodeDiskFillClose$' ./pkg/fileservice
{"Time":"2026-09-15T18:51:30.121865+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSharedDecodeDiskFillClose","Elapsed":0.02}
{"Time":"2026-09-15T18:51:31.132599+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":1.113}

Initial exit: 0.

Adaptive repetition:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=100 -timeout=120s -run '^TestS3FSSharedDecodeDiskFillClose$' -failfast ./pkg/fileservice
{"Time":"2026-09-15T18:51:35.583196+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSharedDecodeDiskFillClose","Elapsed":0.04}
{"Time":"2026-09-15T18:51:36.649779+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":3.977}

Repeat exit: 0; exact top-level run/pass: 100/100; no failures/skips/race reports.

Complete stdout SHA-256:

measurement 458bf4a40554bbb468e6b096167bae56f602e753b028d9cfb40dc91eb06f57eb
stress      b6858e793d748fb2c6a544d11accfb58c6aff6bba9449a177c634f01916b1026
TestS3FSSharedDecodeDiskFillSkipsColdPaths

Initial measurement:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=1 -timeout=120s -run '^TestS3FSSharedDecodeDiskFillSkipsColdPaths$' ./pkg/fileservice
{"Time":"2026-09-15T18:51:39.386471+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSharedDecodeDiskFillSkipsColdPaths","Elapsed":0.07}
{"Time":"2026-09-15T18:51:40.397444+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":1.152}

Initial exit: 0.

Adaptive repetition:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=100 -timeout=120s -run '^TestS3FSSharedDecodeDiskFillSkipsColdPaths$' -failfast ./pkg/fileservice
{"Time":"2026-09-15T18:51:51.625647+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSharedDecodeDiskFillSkipsColdPaths","Elapsed":0.09}
{"Time":"2026-09-15T18:51:52.697296+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":10.767}

Repeat exit: 0; exact top-level run/pass: 100/100; no failures/skips/race reports.

Complete stdout SHA-256:

measurement 6f89200e87483de234ba3ee33db77f2de20ebc620b5dc48044ea84217ef0f794
stress      f14b0f1d55c64981832f9e0282ad8b983e60ee9b66cc9891cf448324fc051678
TestS3FSSharedDecodeDiskHits

Initial measurement:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=1 -timeout=120s -run '^TestS3FSSharedDecodeDiskHits$' ./pkg/fileservice
{"Time":"2026-09-15T18:51:55.833001+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSharedDecodeDiskHits","Elapsed":0.02}
{"Time":"2026-09-15T18:51:56.843975+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":1.106}

Initial exit: 0.

Adaptive repetition:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=100 -timeout=120s -run '^TestS3FSSharedDecodeDiskHits$' -failfast ./pkg/fileservice
{"Time":"2026-09-15T18:52:01.437872+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSharedDecodeDiskHits","Elapsed":0.03}
{"Time":"2026-09-15T18:52:02.499635+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":4.165}

Repeat exit: 0; exact top-level run/pass: 100/100; no failures/skips/race reports.

Complete stdout SHA-256:

measurement 34747799543edbbbce7777722f831fabd6ff602702ea9f4dc1274ea07b8b1098
stress      da2e8517deeb05eb83a5d21bdb0ade71511e4e59533831c1e2e34e49d166a21b
TestS3FSSelectedDecodeReadPaths

Initial measurement:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=1 -timeout=120s -run '^TestS3FSSelectedDecodeReadPaths$' ./pkg/fileservice
{"Time":"2026-09-15T18:52:05.263989+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSelectedDecodeReadPaths","Elapsed":0.05}
{"Time":"2026-09-15T18:52:06.277556+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":1.138}

Initial exit: 0.

Adaptive repetition:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=100 -timeout=120s -run '^TestS3FSSelectedDecodeReadPaths$' -failfast ./pkg/fileservice
{"Time":"2026-09-15T18:52:11.120853+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSelectedDecodeReadPaths","Elapsed":0.03}
{"Time":"2026-09-15T18:52:12.139733+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":4.313}

Repeat exit: 0; exact top-level run/pass: 100/100; no failures/skips/race reports.

Complete stdout SHA-256:

measurement 0b8409de94d914a4c0ad53b92c5a99c202c67826fdf6751f1fc3b8a73d9b4501
stress      0ee004b5d0628ad8eb8551cbf88ae43015be398094a3945b753e6c361f02d6b8
TestS3FSSelectedDecodeFailureIsolation

Initial measurement:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=1 -timeout=120s -run '^TestS3FSSelectedDecodeFailureIsolation$' ./pkg/fileservice
{"Time":"2026-09-15T18:52:13.876325+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSelectedDecodeFailureIsolation","Elapsed":0.03}
{"Time":"2026-09-15T18:52:14.890437+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":1.113}

Initial exit: 0.

Adaptive repetition:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=100 -timeout=120s -run '^TestS3FSSelectedDecodeFailureIsolation$' -failfast ./pkg/fileservice
{"Time":"2026-09-15T18:52:17.915026+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSelectedDecodeFailureIsolation","Elapsed":0.01}
{"Time":"2026-09-15T18:52:18.939744+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":2.476}

Repeat exit: 0; exact top-level run/pass: 100/100; no failures/skips/race reports.

Complete stdout SHA-256:

measurement 0dfecad07879f39cf267e41602d4e2de19bff52243637b26be37bd786f0685df
stress      30238f71afefbd1ece40b663284431a092f173726f75efddd633f91b157ed9b1
TestS3FSSelectedDecodeCloseDuringSibling

Initial measurement:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=1 -timeout=120s -run '^TestS3FSSelectedDecodeCloseDuringSibling$' ./pkg/fileservice
{"Time":"2026-09-15T18:52:20.654067+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSelectedDecodeCloseDuringSibling","Elapsed":0.02}
{"Time":"2026-09-15T18:52:21.665052+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":1.102}

Initial exit: 0.

Adaptive repetition:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=100 -timeout=120s -run '^TestS3FSSelectedDecodeCloseDuringSibling$' -failfast ./pkg/fileservice
{"Time":"2026-09-15T18:52:24.832752+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSelectedDecodeCloseDuringSibling","Elapsed":0.02}
{"Time":"2026-09-15T18:52:25.87087+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":2.645}

Repeat exit: 0; exact top-level run/pass: 100/100; no failures/skips/race reports.

Complete stdout SHA-256:

measurement cb1ca79e2c3bc52ca2d980d8957c509a13487bc52585783f51cb49a6e8974bcf
stress      25ecf5a5ede05754a27c9f718e302b0e156378fbabb6997154c84f7fb3bdf1bf
TestS3FSSharedDecodeCloseDefersCacheRetirement

Initial measurement:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=1 -timeout=120s -run '^TestS3FSSharedDecodeCloseDefersCacheRetirement$' ./pkg/fileservice
{"Time":"2026-09-15T18:52:28.695705+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSharedDecodeCloseDefersCacheRetirement","Elapsed":0.02}
{"Time":"2026-09-15T18:52:29.703788+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":1.098}

Initial exit: 0.

Adaptive repetition:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=100 -timeout=120s -run '^TestS3FSSharedDecodeCloseDefersCacheRetirement$' -failfast ./pkg/fileservice
{"Time":"2026-09-15T18:52:31.942012+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSharedDecodeCloseDefersCacheRetirement","Elapsed":0.01}
{"Time":"2026-09-15T18:52:32.956473+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":1.7610000000000001}

Repeat exit: 0; exact top-level run/pass: 100/100; no failures/skips/race reports.

Complete stdout SHA-256:

measurement c6a23864d911ce47215e382c3c778e287ff6dae13d973d686e583bfa2693de8a
stress      114bceb74fdf06af64ff79138d1b012f1f8ecef228779ac4d8485d7a5f28b06c
TestS3FSSharedDecodeCloseDuringCacheUpdate

Initial measurement:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=1 -timeout=120s -run '^TestS3FSSharedDecodeCloseDuringCacheUpdate$' ./pkg/fileservice
{"Time":"2026-09-15T18:52:34.679162+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSharedDecodeCloseDuringCacheUpdate","Elapsed":0.02}
{"Time":"2026-09-15T18:52:35.693337+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":1.103}

Initial exit: 0.

Adaptive repetition:

cd /private/tmp/mo-column-fill-28898-main-20260915
env GOMAXPROCS=4 LC_ALL=C LANG=C GOWORK=off GOFLAGS= TMPDIR=/private/tmp/mo-28918-review5207499186-evidence/tmp .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -race -json -count=100 -timeout=120s -run '^TestS3FSSharedDecodeCloseDuringCacheUpdate$' -failfast ./pkg/fileservice
{"Time":"2026-09-15T18:52:38.751052+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Test":"TestS3FSSharedDecodeCloseDuringCacheUpdate","Elapsed":0.02}
{"Time":"2026-09-15T18:52:39.808574+08:00","Action":"pass","Package":"github.com/matrixorigin/matrixone/pkg/fileservice","Elapsed":2.518}

Repeat exit: 0; exact top-level run/pass: 100/100; no failures/skips/race reports.

Complete stdout SHA-256:

measurement 656ba4f4d19946ab45f24dd73a3d12f0d9d9372d374b1276a13ce5e4f79e6906
stress      c4a269bf4fb041c2e87e743b87477397c7a90b73fcd7b00819b3ef57149f2548

Owning-package evidence and limits

The previous full pkg/fileservice normal and race runs remain valid: the three changed source files match the final recorded contents byte-for-byte, and the complete log hashes were rechecked. Those runs were captured just before committing these exact file contents; they are reused under the semantic evidence-reuse rule, not misrepresented as newly rerun tests.

Normal: ok github.com/matrixorigin/matrixone/pkg/fileservice 15.592s
Race: ok github.com/matrixorigin/matrixone/pkg/fileservice 24.557s

Source SHA-256:

3badaa894a6f233bb0f9b4171d3e449fea9b7f5c48a6a8af40c1cd92798e7176  pkg/fileservice/shared_decode.go
5b75acd2d276a9c611e3f38bf8e8ba9309c75c11d0fbf93802f17339b9cdc0b9  pkg/fileservice/s3_fs.go
73968fdfc4a6dfbc4ef8333f447a0ff8abe3c26e867c0fa24471f47c1ec3c7ae  pkg/fileservice/shared_decode_test.go

Full-package log SHA-256:

5e23357bcd3f56bf46b53adb9abe964c9018180baa06be0fd4b371cdb21fcf1a  normal
560262e4f889b1fbf7beaedcb722527b2cf309a026a4291e017cbdab1e6e3a55  race

The separate Linux full UT run and multi-CN proxy BVT also passed. They are supplementary evidence, not a substitute for the individual race protocol.

This closes the requested validation-evidence gap; it is not a claim of exhaustive race freedom or a proof of zero performance regression in every workload. The head is unchanged. Please re-review the evidence above.

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

Reviewed commit 1de99ef. The previous validation-evidence gap is closed by the per-test race runs. No blocking correctness, lifecycle, compatibility, or performance regression was identified. APPROVE.

XuPeng-SH added a commit that referenced this pull request Sep 16, 2026
## What type of PR is this?

- [x] Test and CI

## Context

The reproduced mechanism from #28898 is already fixed by #28918, and
#28888 covers full-object pending-publication rereads. The daily
full-object assessment identified a policy boundary that needs to remain
explicit.

PR #12198 intentionally made the default S3FS read a full-object read
and enabled reuse through the disk-cache full-file artifact. A sparse
row selection alone is not sufficient evidence to replace that default:
legacy vector decoding still follows the whole-column path, and later
projected columns can benefit from the same full object.

## What this PR does

- Adds a disk-backed S3FS regression guard that verifies `Policy(0)`
requests `[0, EOF)` while `SkipFullFilePreloads` remains an explicit
bounded-range opt-in.
- Adds legacy ObjectIO TopN sparse/dense/explicit-range coverage so
legacy TopN does not accidentally inherit the chunked path range policy.
- Does not change production code, the default cache policy, prefetch
behavior, DiskCache admission/eviction, or SQL semantics.

This is a follow-up safety guard, not a claim of an end-to-end
Daily/Wiki performance improvement.

## Validation

- `GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -count=1
-timeout=600s ./pkg/objectio`
- `GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -count=1
-timeout=600s ./pkg/fileservice`
- `GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1
-timeout=600s ./pkg/objectio`
- `GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1
-timeout=600s ./pkg/fileservice`
- `go vet -mod=readonly ./pkg/objectio ./pkg/fileservice` with the
repository CGo include/link environment
- `git diff --check`

BVT: N/A. This change only adds internal FileService/ObjectIO regression
coverage and does not change SQL behavior.

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…rixorigin#28918)

## 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:

Fixes matrixorigin#28898: the reproduced main-branch same-key disk-read/decode
amplification mechanism.

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

### Problem

After concurrent MemCache misses, readers of the same immutable column
can each read its DiskCache extent before any reader publishes decoded
data. Existing scoped decode sharing starts after disk I/O and has a
bounded admission quota. When that quota is exhausted, duplicate decoded
allocations can evict useful cache entries before MemCache insertion
detects the duplicate key.

This causes avoidable read/decode amplification even when the working
set fits MemCache. It is distinct from the existing cold-object S3
IOMerger path.

### Narrow change

- Coordinate an already `DecodeSharing`-marked immutable column at the
`S3FS.Read` boundary, before disk I/O. Keep the existing
one-selected-column eligibility and policy checks.
- Enter only when DiskCache's existing index reports the full file
present, or the exact range for a single-entry request. The index is a
hint, not a substitute for the actual read.
- Recheck MemCache before I/O. Successful disk-fill leaders notify
followers only after deferred MemCache publication; followers then read
through the normal cache API.
- Do not start a new fill when pending memory reservations or an active
memory-pressure target make publication unsuitable. This read-only hint
does not reserve or evict anything, and existing same-key fills can
still accept followers.
- Leave coordination before remote-cache/S3 work when the disk read is
incomplete. Cold/unindexed paths do not acquire a fill ticket.

### Lifecycle and bounds

- Reuse the existing FileService decoded-read registry and close/read
lifetime. The new records hold notification metadata only, not decoded
buffers.
- Limit live fill generations to 64 and participants per generation to
128. Detached generations remain charged until their final participant
releases them.
- At most one added fill wait per Read, bounded by one second and
interruptible by cancellation or service close. Timeout/admission bypass
resumes the existing read path without rejoining the fill.
- Completion is a notification, not a shared error result: a failed or
canceled leader does not turn a healthy follower into a failed read.
- No new goroutines, global disk throttle, cache-budget/eviction
changes, SQL/planner changes, routing changes, configuration, production
hooks, or persistent-format changes.

### Tests and validation

The committed UTs cover same-key disk-fill reuse with available and
saturated decode-sharing admission, publication-before-notification, key
isolation, participant/generation limits, cancellation, timeout, close,
stale-generation release, memory admission, and cold-path bypass. They
also retain the existing independent fallback coverage.

Validation on the final file contents, based on upstream main
`2ea4ec2e6ef4b20321a235ef416228506813e39b`:

| Validation | Result |
| --- | --- |
| Full FileService package, normal | PASS, 15.592s |
| Full FileService package, race | PASS, 24.557s |
| Focused disk-fill/shared-decode tests, race x30 | PASS, 13.278s |
| Linux FileService integration, four CPUs, x5 | PASS |
| Same Linux integration, race | PASS |
| `go vet ./pkg/fileservice`, formatting, diff checks | PASS |

The separate Linux integration uses real FileService, DiskCache,
MemCache, native allocation and LZ4 with the local disk-backed
object-storage endpoint. Its baseline is
`bb358ea76aeb44a6eed5079616e7e75ba35e75b9`; the candidate adds only the
two production files. FileService/ObjectIO production code and
dependency versions were checked for equivalence between that baseline
and the main base above. The external diagnostic harness is not added to
this PR.

For eight overlapping requests for one missing immutable column, with
seven other columns warm and decode sharing saturated:

| Counter | Baseline | Candidate |
| --- | ---: | ---: |
| Disk reads | 8 | 1 |
| Conversions | 8 | 1 |
| Logical disk bytes | 295,224 | 36,903 |
| Retained MemCache data after the wave | 1 MiB | 8 MiB |

Payload equality and reservation/registry cleanup are checked. The cold
control remains one source GET, zero disk hits and one conversion.
Different-key, memory-hit, single-reader and non-admitting controls are
also exercised.

Adjacent four-core benchmark samples on the final candidate did not
reproduce a sustained regression in different-key or memory-ineligible
overlapping reads. Samples contain host noise and are not a universal
no-regression or speedup claim; the metadata coordination has a small
allocation cost.

Reproducible owning-package checks, with the repository-supported Go/CGo
environment:

```sh
GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/fileservice
GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/fileservice
GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=30 -timeout=600s \
  -run '^(TestSharedDecodeFill.*|TestS3FSSharedDecodeDiskFill.*|TestS3FSSharedDecodeDiskHits)$' \
  ./pkg/fileservice
```

### Scope and evidence limits

This fixes the reproduced mechanism with bounded coordination; it does
not guarantee that every same-key miss will coalesce under timeout,
cache eviction or admission pressure. Full IVF-10M SQL latency recovery
and the fraction of nightly multi-TB traffic attributable to this
mechanism have not been validated. No external COS test, cluster rollout
or 4.2 backport is claimed.

Self-review covered publication ordering, ownership, all ticket terminal
paths, cancellation/close, stale generations and resource bounds. No
unresolved blocker was found in this scope.

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…rigin#29017)

## What type of PR is this?

- [x] Test and CI

## Context

The reproduced mechanism from matrixorigin#28898 is already fixed by matrixorigin#28918, and
matrixorigin#28888 covers full-object pending-publication rereads. The daily
full-object assessment identified a policy boundary that needs to remain
explicit.

PR matrixorigin#12198 intentionally made the default S3FS read a full-object read
and enabled reuse through the disk-cache full-file artifact. A sparse
row selection alone is not sufficient evidence to replace that default:
legacy vector decoding still follows the whole-column path, and later
projected columns can benefit from the same full object.

## What this PR does

- Adds a disk-backed S3FS regression guard that verifies `Policy(0)`
requests `[0, EOF)` while `SkipFullFilePreloads` remains an explicit
bounded-range opt-in.
- Adds legacy ObjectIO TopN sparse/dense/explicit-range coverage so
legacy TopN does not accidentally inherit the chunked path range policy.
- Does not change production code, the default cache policy, prefetch
behavior, DiskCache admission/eviction, or SQL semantics.

This is a follow-up safety guard, not a claim of an end-to-end
Daily/Wiki performance improvement.

## Validation

- `GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -count=1
-timeout=600s ./pkg/objectio`
- `GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -count=1
-timeout=600s ./pkg/fileservice`
- `GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1
-timeout=600s ./pkg/objectio`
- `GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1
-timeout=600s ./pkg/fileservice`
- `go vet -mod=readonly ./pkg/objectio ./pkg/fileservice` with the
repository CGo include/link environment
- `git diff --check`

BVT: N/A. This change only adds internal FileService/ObjectIO regression
coverage and does not change SQL behavior.

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…rixorigin#28918)

## 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:

Fixes matrixorigin#28898: the reproduced main-branch same-key disk-read/decode
amplification mechanism.

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

### Problem

After concurrent MemCache misses, readers of the same immutable column
can each read its DiskCache extent before any reader publishes decoded
data. Existing scoped decode sharing starts after disk I/O and has a
bounded admission quota. When that quota is exhausted, duplicate decoded
allocations can evict useful cache entries before MemCache insertion
detects the duplicate key.

This causes avoidable read/decode amplification even when the working
set fits MemCache. It is distinct from the existing cold-object S3
IOMerger path.

### Narrow change

- Coordinate an already `DecodeSharing`-marked immutable column at the
`S3FS.Read` boundary, before disk I/O. Keep the existing
one-selected-column eligibility and policy checks.
- Enter only when DiskCache's existing index reports the full file
present, or the exact range for a single-entry request. The index is a
hint, not a substitute for the actual read.
- Recheck MemCache before I/O. Successful disk-fill leaders notify
followers only after deferred MemCache publication; followers then read
through the normal cache API.
- Do not start a new fill when pending memory reservations or an active
memory-pressure target make publication unsuitable. This read-only hint
does not reserve or evict anything, and existing same-key fills can
still accept followers.
- Leave coordination before remote-cache/S3 work when the disk read is
incomplete. Cold/unindexed paths do not acquire a fill ticket.

### Lifecycle and bounds

- Reuse the existing FileService decoded-read registry and close/read
lifetime. The new records hold notification metadata only, not decoded
buffers.
- Limit live fill generations to 64 and participants per generation to
128. Detached generations remain charged until their final participant
releases them.
- At most one added fill wait per Read, bounded by one second and
interruptible by cancellation or service close. Timeout/admission bypass
resumes the existing read path without rejoining the fill.
- Completion is a notification, not a shared error result: a failed or
canceled leader does not turn a healthy follower into a failed read.
- No new goroutines, global disk throttle, cache-budget/eviction
changes, SQL/planner changes, routing changes, configuration, production
hooks, or persistent-format changes.

### Tests and validation

The committed UTs cover same-key disk-fill reuse with available and
saturated decode-sharing admission, publication-before-notification, key
isolation, participant/generation limits, cancellation, timeout, close,
stale-generation release, memory admission, and cold-path bypass. They
also retain the existing independent fallback coverage.

Validation on the final file contents, based on upstream main
`2ea4ec2e6ef4b20321a235ef416228506813e39b`:

| Validation | Result |
| --- | --- |
| Full FileService package, normal | PASS, 15.592s |
| Full FileService package, race | PASS, 24.557s |
| Focused disk-fill/shared-decode tests, race x30 | PASS, 13.278s |
| Linux FileService integration, four CPUs, x5 | PASS |
| Same Linux integration, race | PASS |
| `go vet ./pkg/fileservice`, formatting, diff checks | PASS |

The separate Linux integration uses real FileService, DiskCache,
MemCache, native allocation and LZ4 with the local disk-backed
object-storage endpoint. Its baseline is
`bb358ea76aeb44a6eed5079616e7e75ba35e75b9`; the candidate adds only the
two production files. FileService/ObjectIO production code and
dependency versions were checked for equivalence between that baseline
and the main base above. The external diagnostic harness is not added to
this PR.

For eight overlapping requests for one missing immutable column, with
seven other columns warm and decode sharing saturated:

| Counter | Baseline | Candidate |
| --- | ---: | ---: |
| Disk reads | 8 | 1 |
| Conversions | 8 | 1 |
| Logical disk bytes | 295,224 | 36,903 |
| Retained MemCache data after the wave | 1 MiB | 8 MiB |

Payload equality and reservation/registry cleanup are checked. The cold
control remains one source GET, zero disk hits and one conversion.
Different-key, memory-hit, single-reader and non-admitting controls are
also exercised.

Adjacent four-core benchmark samples on the final candidate did not
reproduce a sustained regression in different-key or memory-ineligible
overlapping reads. Samples contain host noise and are not a universal
no-regression or speedup claim; the metadata coordination has a small
allocation cost.

Reproducible owning-package checks, with the repository-supported Go/CGo
environment:

```sh
GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/fileservice
GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/fileservice
GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=30 -timeout=600s \
  -run '^(TestSharedDecodeFill.*|TestS3FSSharedDecodeDiskFill.*|TestS3FSSharedDecodeDiskHits)$' \
  ./pkg/fileservice
```

### Scope and evidence limits

This fixes the reproduced mechanism with bounded coordination; it does
not guarantee that every same-key miss will coalesce under timeout,
cache eviction or admission pressure. Full IVF-10M SQL latency recovery
and the fraction of nightly multi-TB traffic attributable to this
mechanism have not been validated. No external COS test, cluster rollout
or 4.2 backport is claimed.

Self-review covered publication ordering, ownership, all ticket terminal
paths, cancellation/close, stale generations and resource bounds. No
unresolved blocker was found in this scope.

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…rigin#29017)

## What type of PR is this?

- [x] Test and CI

## Context

The reproduced mechanism from matrixorigin#28898 is already fixed by matrixorigin#28918, and
matrixorigin#28888 covers full-object pending-publication rereads. The daily
full-object assessment identified a policy boundary that needs to remain
explicit.

PR matrixorigin#12198 intentionally made the default S3FS read a full-object read
and enabled reuse through the disk-cache full-file artifact. A sparse
row selection alone is not sufficient evidence to replace that default:
legacy vector decoding still follows the whole-column path, and later
projected columns can benefit from the same full object.

## What this PR does

- Adds a disk-backed S3FS regression guard that verifies `Policy(0)`
requests `[0, EOF)` while `SkipFullFilePreloads` remains an explicit
bounded-range opt-in.
- Adds legacy ObjectIO TopN sparse/dense/explicit-range coverage so
legacy TopN does not accidentally inherit the chunked path range policy.
- Does not change production code, the default cache policy, prefetch
behavior, DiskCache admission/eviction, or SQL semantics.

This is a follow-up safety guard, not a claim of an end-to-end
Daily/Wiki performance improvement.

## Validation

- `GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -count=1
-timeout=600s ./pkg/objectio`
- `GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -count=1
-timeout=600s ./pkg/fileservice`
- `GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1
-timeout=600s ./pkg/objectio`
- `GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1
-timeout=600s ./pkg/fileservice`
- `go vet -mod=readonly ./pkg/objectio ./pkg/fileservice` with the
repository CGo include/link environment
- `git diff --check`

BVT: N/A. This change only adds internal FileService/ObjectIO regression
coverage and does not change SQL behavior.

Co-authored-by: XuPeng-SH <[email protected]>
XuPeng-SH added a commit that referenced this pull request Nov 8, 2026
) to 4.2-dev (#32361)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

Fixes #32223

Backport of #28918 and the scoped column-decode prerequisite from #28413
to `4.2-dev`.

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

Concurrent reads of the same immutable array column can all miss
MemCache and independently read and decompress a warm DiskCache extent.
For eligible scoped Top-N reads, coordinate a bounded warm-disk fill and
reuse an immutable decoded result while overlapping consumers hold their
read vectors. Followers recheck the existing MemCache and fall back
independently on rejection, wait timeout, or failed work; caller
cancellation and a close observed by a failed disk conversion stop
before another tier.

The 4.2 FIFO cache remains responsible for admission and eviction;
restore its existing pre-allocation eviction and remove the separate
reservation counter. Decode generations have their own bounded lifetime
and addressable-backing budget, with unknown or oversized results
bypassing sharing. No SQL, wire, catalog, or on-disk format changes are
required.

## Validation

- Go 1.26.4 and 4.2-built native libraries: full normal and race tests
for `pkg/fileservice`, `pkg/fileservice/fifocache`, `pkg/objectio`,
`pkg/objectio/ioutil`, `pkg/util/metric/v2`, and the
`pkg/vm/engine/tae/blockio` consumer.
- CI coverage flags (`-short -tags matrixone_test -covermode=set` and
the CI list of 439 instrumented packages) against those owning/consumer
packages, including the formerly failing FileService and ObjectIO tests.
This is not a full repository CI run.
- Twelve exact concurrency/lifecycle/CI regression tests passed adaptive
race repetitions (14–100 per test, using a 30-second target and the
measured per-test runtime). A persisted S3FS `LoadColumnDataByTopN` test
compares shared and unshared results with real cache rejection,
different queries, selections, bounds, and cleanup.
- Incremental `gofmt -s`, `go vet`, MatrixOne `molint`, and
repository-configured `golangci-lint` over the affected closure and
complete PR patch.
- On 4.2, three 1-second samples of a controlled warm-disk Top-N pair
retained two decoded owners without sharing and one with sharing; median
latency was 184.9 µs versus 171.0 µs, with 120 versus 134 allocations
per pair. This is a small, forced-overlap mechanism test, not evidence
of restored 10M-workload QPS. In an admissible eight-reader warm-fill
control, disk reads fell from about 4.46 to 1 per batch and median time
from 279 to 226 µs. Other FileService controls cover pressure rejection,
memory hits, independent keys, and cold object-store reads. A separate
unscoped baseline/current control kept allocation counts unchanged (5
per memory hit and 53 per cold read); the larger entry increased
measured bytes per operation by about 32 and 65 bytes respectively.

The separate CI failure in
`TestIssue27966FrontendIVFInternalSQLPreservesQueryPool` occurred during
initial four-CN label setup with HAKeeper timeouts, before its SQL
workload; a direct causal connection to this change has not been
established. The same four-CN test passed locally on this revision in
normal mode and under `-race`.

---------

Co-authored-by: bRong Njam <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: GreatRiver <[email protected]>

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/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: FileService: concurrent disk-cache hits duplicate reads/decodes and can evict warm entries before key deduplication

3 participants