Repository navigation
fix: account for merge block capacity and avoid sparse S3 overreads - #32914
Conversation
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? |
|
This pull request is merged. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: d7faec5869f69cbfeac831de8a67b1dca3bcabfa
Assessment: approve
Merge admission and merge-start logging use the table’s block capacity through the existing estimator and retain the 8,192-row floor. Sparse buffered reads use the existing amplification threshold and cap splitting at four misses. Validation covered streaming, full-file cache fills, short reads, and cache publication after an error.
Model: gpt-6.2-sol / xhigh
Session: 01a1ee7f-fdcb-7b83-ad57-3b17a0e9d494 · slot 1 · generation 1
Validation:
-
The frozen patch and native build inputs matched,
git diff --checkpassed, and runtime preflight passed. Seesource-and-native.logandpreflight.log. -
The selected fileservice run passed 86 top-level tests. Focused S3 lifecycle and cache-publication tests also passed under
-race. Seefileservice-owner-paths.log,s3-race.log, and receipts1795058277759514713-2and1795058107251910379-2. -
The mergesort, merge scheduler, and catalog packages passed in short mode. Downstream merge, tombstone merge, and partial-read cleanup tests passed. See
owning-packages.log,downstream-tests.log, and receipts1795058168969984458-2and1795057985285027328-2. -
In four baseline and candidate samples, two sparse 4 KiB ranges went from one GET transferring 16,781,312 bytes to two GETs transferring 8,192 bytes. Allocated bytes fell from about 36.2 MB to 23.6 KB per read. Cacheless dense controls kept their request and allocation counts, and memory-cache hits stayed at three allocations per read. The custom vector-cache control added one allocation and 16 bytes per read. See the retained
s3-*-comparison.logands3-*-memory-hit.logfiles and their matching receipts.
Limitations:
-
The full fileservice run timed out in
TestIndexFileCacheConcurrentOperationswhile the unchanged index-cache path was syncing directories. The direct follow-up passed on the affected fileservice paths. -
The benchmarks used generated storage, and the short-read control used the local disk adapter. Production S3 latency and merge peak RSS remain unmeasured.
|
mo-bot review · Commit: New discussion was assessed; the previous review remains unchanged. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
The new(bool) raised in the prior review is gone in this head. I found an integration gap and a cleanup item:
-
[P2] Unify short-object handling in both per-entry read paths. The new ordinary sparse loop in
S3FS.readconverts a 416 from a later range intoErrUnexpectedEOF, but the existingreadEntriesIndividuallystill callss.read(..., laterSparseRange=false)for every entry. A real disk-cache download that declines the requested ranges setsdownloadDeclined, which routes the same sparse IOVector through that older path. If its first range succeeds and the second is past the object end, this path returns the storage's raw 416 instead of the file-serviceErrUnexpectedEOFcontract. The full-file streaming fallback uses the same helper. In an exact-head probe with the documented declined-download state and a 416 on the second storage read, the ordinary path returnedErrUnexpectedEOF, while the fallback returned raw 416. This discrepancy existed in the older fallback, but the new split adds a second implementation and only fixes the new one. Please consolidate the per-entry loop and cover both entry routes, including first-versus-later range failure and cleanup. -
EstimateMergeSizenow has no production callers; the only remaining caller is its new test. Please remove that compatibility wrapper and test the default/floor behavior through the live estimator, so the replaced API does not survive solely to test itself. Consider making the block-capacity method part ofcatalog.MergeTableas well: the current optional assertion silently falls back to 8192 for any future implementation, undermining the admission estimate this patch introduces.
The prior review's new(bool) concern is structurally addressed; its GitHub review is still marked changes requested and should be revisited by that reviewer. The local failure probe models the disk-cache decline and storage response; it is not a live S3 benchmark.
Skip sparse classification for ordinary dense and singleton reads. Retain independent range bounds with two scalar snapshots instead of allocating entry copies. Signed-off-by: XuPeng-SH <[email protected]>
db70b9d to
f62d58e
Compare
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: f62d58ec231b356fed9200b01aee5ac1d5cfca76
Assessment: approve
Merge admission and merge-start logging share the schema-aware estimator and preserve the 8,192-row floor for existing objects. Sparse buffered S3 reads reuse the existing per-entry reader and publish cache entries only after success. Keeping one range for ordinary HDFS reads resolves the earlier short-read finding.
Model: gpt-6.2-sol / xhigh
Session: 01a1f0a0-5126-78f3-9ab8-ef4e87f2f119 · slot 0 · generation 3
Validation:
-
Verified the frozen head, merge base, full patch, clean checkout, formatting, isolation preflight, and retained native inputs. See scope-verification.log, final-source.log, format.log, preflight.log, and native-verified.log.
-
Short-mode race checks passed for mergesort, the merge scheduler, catalog, and the focused fileservice paths. The targeted normal fileservice run passed 95 top-level tests. See merge-race.jsonl, fileservice-race.jsonl, and fileservice-owner-normal.jsonl with receipts 1795311975197809627-3, 1795312028239625264-3, and 1795312538445250042-2.
-
Downstream data merge, tombstone merge, and partial-read cleanup tests passed. The MinIO SDK over loopback preserved HTTP 416 on the first range and returned ErrUnexpectedEOF on a later sparse range. See merge-downstream.jsonl, objectio-downstream.jsonl, and minio-range.jsonl with receipts 1795312172968112752-2, 1795312067776340667-2, and 1795312169519934846-2.
-
Generated-storage benchmarks reduced two sparse 4 KiB reads from 16,781,312 bytes in one GET to 8,192 bytes in two GETs. Allocated bytes fell from about 36.24 MB to 23.2 KB per read. Same-core controls confirmed one GET for single, adjacent, and dense reads. The 64-entry dense control fell from 287 to 158 allocations per read. See range-bench-baseline.log, range-bench-candidate.log, and range-same-core-*.log.
Limitations:
-
The broader fileservice run excluded TestIndexFileCacheConcurrentOperations after an earlier timeout and reached its 120-second limit during TestIndexFileCacheReleaseSuperseded. The targeted follow-up passed. See fileservice-normal.jsonl and receipt 1795312386872437835-2.
-
HDFS coverage used a seek model based on the pinned SDK. Benchmark timings varied, and live object-store latency and production peak merge memory remain unmeasured.
-
Shared build, x86 unit tests, arm64 static analysis, and coverage were still running in the frozen CI snapshot.
) ## What type of PR is this? - [x] BUG - [x] Test and CI ## Which issue(s) this PR fixes: Related to #31475 and #31703. The failing coverage test was observed on #32914. ## What this PR does / why we need it: When KILL QUERY interrupted a `LOAD DATA LOCAL` upload, closing the pipe reader caused the SQL consumer to see `io.ErrClosedPipe`. The client could receive MySQL error 1105 for the interrupted query. Close the upload pipe writer with the cancellation error so the consumer receives it and the existing protocol mapping returns MySQL error 1317 / SQLSTATE 70100. The upload owner still drains a finite client stream before the session is reused. The regression captures the consumer error while the finite tail is pending and checks it after the upload owner has joined. ## Validation - The deterministic pipe regression returned `io.ErrClosedPipe` on clean main at `96d0d01872`. - The full frontend package passed with the race detector in short mode. All seven `TestKillLoadLocal` wire scenarios passed under race and 12 times each with coverage enabled. - The focused pipe regression and the partial-payload wire scenario also passed 100 race repetitions each on the identical fix. - Formatting, diff checks, err-check, vet, golangci-lint and molint passed for the affected scope. Signed-off-by: XuPeng-SH <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…_merge The tests matrixorigin#32914 adds read through this branch's file service: they reserve an async finalize with its context, pass read its fourth argument, and read with no range prefetch, and without prefetch objects where storage counts its reads. A read served by the index-file cache runs its queued cache updates. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The tests matrixorigin#32914 adds read through this branch's file service: they reserve an async finalize with its context, pass read its fourth argument, and read with no range prefetch, and without prefetch objects where storage counts its reads. A read served by the index-file cache runs its queued cache updates. Co-Authored-By: Claude Opus 5.5 <[email protected]>
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to #33203 ## What this PR does / why we need it: Backport the aggregate Merge memory-admission safeguard from #33244 to `4.2-dev`. The branch does not yet contain #32911, so this PR also cherry-picks its prerequisite: reserve memory before submitting each Merge task, skip denied work, and release a reservation if submission fails. Without that prerequisite, a tighter `Acquire` policy would not stop the task from running. Adapt the safeguard to `4.2-dev`'s `defaultAcquirePolicy`: the sum of Merge reservations must fit within two thirds of the currently sampled TN memory headroom. This accounts for memory already used by other TN work; non-Merge throttlers retain their existing policy. Keep memory-denied one-shot manual Merge tasks in a bounded retry queue. When the active task completes, wake the scheduler to retry the denied work within the retry window, including when the table is paused and the normal scan interval is longer than the window. Completion notifications target the active scheduler generation and validate the table supporter before waking its queue. Retained manual retries are rearmed on restart. Denied retries rotate so an expensive request cannot hide a smaller one, and pausing a table preserves the next manual retry check. The latest review gaps are closed: an ALTER commit refreshes the existing table supporter without losing its retry queue or in-flight accounting; expired retries release their object metadata even under low memory or PauseAll; and the scheduler checks recovered capacity before the retry deadline, with a final admission opportunity at the deadline. The next review found three further edges. Named-object inspect commands carry only object names, so the scheduler now resolves visible catalog statistics before estimating and admitting those tasks; missing objects cannot receive a zero-byte reservation. A delayed vacuum callback captures the table reference when scheduled, avoiding a race with an ALTER refresh. The final retry permits one admission attempt when its deadline timer fires slightly late, then expires retained candidates after a bounded five-second grace period. The latest review found that pre-admission memory trimming could silently remove an object from a named manual Merge request. Named-object tasks now retain their complete input set through estimation; admission rejects and retries the whole request when capacity is insufficient. The regression test makes the two-object estimate exceed the gathering threshold while one object fits, and verifies the full request reaches admission and remains queued after denial. The latest review's three remaining edges are addressed. A deferred named merge checks every requested object at executor lookup and again when its transaction task is created; if any input disappeared, the whole task is rejected. A transient executor rejection, including a dispatcher scope conflict before the old scope is released, keeps the complete request in the existing bounded retry queue. The retry test waits for scheduler admission to finish before asserting that the completion released its reservation. The newest review's remaining issues are also addressed: the launch pad clears its reusable pointer-bearing slices after gathered tasks have been admitted or transferred to retries, so an expired retry does not leave catalog objects reachable there. The exact merge task constructor re-reads each object's current catalog version before accepting the task, catching a drop intent installed after executor lookup. The queued completion regression now waits for scheduler admission before asserting reservation release. Validation on `4.2-dev` at `d497cc1584`: focused admission and named-object regressions passed; three affected timing and ownership regressions passed 25 race repetitions; the full `rscthrottler` and Merge scheduler packages passed with `-race`, and the Merge job package compiled. Scoped `go vet` with the repository CGo include paths, `gofmt`, and `git diff --check` passed. The previous PR head passed all 34 checks; CI for this head is pending. The PR diff covers the Merge scheduler, executor, merge job constructor, resource throttler, and their regression tests. This is an estimate-based admission safeguard, not a strict process-memory cap. The separate block-row estimate improvement from #32914 is not part of this backport. Approved-by: XuPeng-SH <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
Related to #32278 (C04 and C05; the umbrella issue remains open).
What this PR does / why we need it:
Include the table's configured block capacity in merge memory admission and the merge-start estimate. Existing input objects can contain default-sized blocks even when the current schema specifies fewer rows, so the estimate retains the 8,192-row floor; configurations above that floor increase the input-block estimate.
Read a small number of ordered, buffered sparse S3 misses individually when the existing range-amplification threshold is exceeded. Keep the envelope for dense, unordered, streaming, or more than four misses, and retain full-file cache-fill behavior. A later object-store 416 after a successful first range remains an unexpected EOF. Failed reads do not publish partially completed cache entries, and cache-update failures keep their existing non-fatal behavior.
Reuse the resolved bounds to bypass sparse-range classification on short ranges and single-entry reads. For other candidates, stop at the fifth miss or at the first unordered or streaming miss. Compute the bounds using two scalar values, so a read no longer copies entries to keep their offsets alive.
In a local ten-sample cacheless public-read benchmark with a generated reader, two 4 KiB ranges 16 MiB apart consumed 8,192 bytes in two GETs versus 16,781,312 bytes in one GET; allocation bytes fell by more than 99%. Single and adjacent controls retained their request and allocation counts. This is a bounded request-count/bytes tradeoff; it does not establish the cause of the original production heap peak.
Validation
7f6729277e. Migrated the reservation probes added by fix(merge): reserve memory before scheduling tasks #32911 to the schema-aware estimate. The inline completion probe now uses 16,384-row blocks and asserts the amounts reserved and released, including executor rejection.TestMergeBlocks,TestTombstoneMergeKeepsTargetDroppedAfterSnapshot, andTestReadOneBlockWithMetaReleasesPartialReadOnError.go vetandgolangci-lint.The C03 reservation ownership fix is separate in #32911. This change does not close the umbrella issue; end-to-end heap/RSS and object-store measurements remain future work.