Skip to content

fix(spill): retain JOIN and HashBuild cleanup ownership on errors - #30102

Open
Ariznawlll wants to merge 63 commits into
matrixorigin:mainfrom
Ariznawlll:codex/spill-join-handoff-retry
Open

Ariznawlll wants to merge 63 commits into
matrixorigin:mainfrom
Ariznawlll:codex/spill-join-handoff-retry

Conversation

@Ariznawlll

@Ariznawlll Ariznawlll commented Oct 13, 2026 •

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 #30097. Fixes #30098. Fixes #30100. Fixes #30103.

Current head and verification (2026-12-03)

Head fa509be249 integrates main 3a1d7780c7. The two bundled CNs now use distinct LOCAL directories through #30814. An intentionally duplicated physical root still requires exclusive ownership.

The additional code change preserves the original error when spill cleanup succeeds. Before the change, the ordinary probe-scatter regression received a Go wrapper around the MatrixOne transaction retry error. It now receives the original typed error, while a simultaneous cleanup failure retains both causes. Producer and post-handoff cleanup remain covered independently. Named-file unlink failures retain the disk charge and fence the affected root; recovery uses CN restart and startup cleanup under the existing design.

  • Linux amd64 and macOS arm64 each passed the normal and race suites for all 12 affected packages, including the three JOIN operators, HashBuild, spillutil, message, and fileservice.
  • The bundled two-CN launch on each platform passed the complete JOIN SQL suite (1,286/1,286, including 96/96 in spill.sql).
  • On Linux the producer, consumer, cleanup/retry and concurrent close regressions passed 20 race-enabled repetitions. The full pkg/embed suite passed in 359.648 s, including the current publication-lock fixture corresponding to the previous Ubuntu CI failure.
  • The prior coverage worker timed out installing its runner dependencies. Hosted CI for the current head is separate from these local runs.

What this PR does / why we need it:

Consolidated candidate for #30099 and #30102. Both branches carry the same implementation, including the distinct JOIN/HashBuild regression oracles; they are not independent fixes.

Anonymous spill descriptors are published only after successful unlink. Named GROUP/HashBuild/JOIN files keep FD rotation and are deleted synchronously by their terminal owner. A removal failure fences further spill creation for that root and preserves conservative disk charges without retaining ended queries or background retry callbacks. Recovery requires old owners to stop, successful startup cleanup and a fresh CN process.

The directing user approved design revision 4; the approval record identifies the exact artifact and availability tradeoff. This is not an assertion of approval by GitHub maintainers; the prior reviews remain for human re-review.

Updated to main 9e29011e7313a57962adc00963baa659d1e81e37 without rewriting history. Follow-up 0fc9b99adf:

  • Only CN initializes/leases/cleans the spill root. TN/LOG sharing LOCAL must not delete CN files or prevent CN startup; a real role-initialization regression covers both boundaries.
  • Preserve the concrete root provider in WINDOW's descriptor-tracking fixture, retaining the original cancellation, descriptor-close and reuse assertions.
  • Use repository moerr constructors while preserving distinct error sentinels and cleanup causes; retain main's index-cache shutdown alongside spill-root shutdown.

Validation

Local Darwin/arm64, Go 1.27.1, repository-controlled native build and provenance with verified pinned dependencies:

  • All 11 affected owning packages pass normal and race suites (3,767 passing test events and 7 existing opt-in/environment-dependent skips in each mode).
  • 24 focused regression events pass in both modes; six exact concurrency tests each pass 100 adaptive race repetitions.
  • The previously failing WINDOW cancellation test also passes atomic coverage instrumentation; this is not an overall CI coverage-rate claim.
  • Standard go vet, make err-check, gofmt and diff checks pass. Configured incremental SCA completes with Go 1.27.1-built pinned tools; golangci-lint v2.14.0 reports 0 issues under the unchanged repository configuration. Molint emits non-failing diagnostics in two unchanged main files (disk_cache_async.go, window.go).

Limits

No Linux runtime, whole-CN restart, SQL/BVT, shared-cluster/production fault injection or performance acceptance was run locally. Private lease tests do not certify whole-CN recovery. Push-triggered CI is separate from local evidence; no workflow was manually dispatched, and pending or skipped checks are not claimed as passes.

@Ariznawlll Ariznawlll changed the title fix(spill): retain JOIN cleanup owner across constructor and teardown failures fix(spill): retain JOIN and HashBuild cleanup ownership on errors Oct 13, 2026
Replace the superseded retry design with anonymous unlink-before-publish, synchronous named cleanup, sticky root exclusion and terminal disk abandonment. Preserve distinct GROUP and JOIN/HashBuild ownership oracles in focused regressions.

Revision 4 was explicitly approved by the task owner. This is a local implementation checkpoint: final post-edit race/static validation and push remain blocked by insufficient local disk space, as recorded in the verification document.
@mergify

mergify Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

⚠️ The sha of the head commit of this PR conflicts with #30099. Mergify cannot evaluate rules on this PR. Once #30099 is merged or closed, Mergify will resume processing this PR. Until then, the Mergify Merge Protections status of this commit reports the merge protections of #30099, not this PR's. ⚠️

@mergify

mergify Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

⚠️ The sha of the head commit of this PR conflicts with #30099. Mergify cannot evaluate rules on this PR. Once #30099 is merged or closed, Mergify will resume processing this PR. Until then, the Mergify Merge Protections status of this commit reports the merge protections of #30099, not this PR's. ⚠️

@mergify

mergify Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

⚠️ The sha of the head commit of this PR conflicts with #30099. Mergify cannot evaluate rules on this PR. Once #30099 is merged or closed, Mergify will resume processing this PR. Until then, the Mergify Merge Protections status of this commit reports the merge protections of #30099, not this PR's. ⚠️

@XuPeng-SH

XuPeng-SH commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 8980d414396686842035ac0bd38bc9c1a16be161

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: 8980d414396686842035ac0bd38bc9c1a16be161

Assessment: approve

Reviewed the complete 37-file delta and all 21 discussion items. Prior ownership and design concerns are resolved or superseded by the approved local lifecycle. No actionable unresolved defects found.

Model: gpt-6-astra / xhigh

Session: 01a1869d-999c-7481-b340-ae4a63e8cee4 · slot 1 · generation 2

Validation:

  • Verified the approved design blob, cleanup/accounting ownership, admission fencing, and shutdown ordering.

  • Reused supplied exact-head CI successes for build, Ubuntu UT, static analysis, coverage, and multi-CN BVT.

  • Isolation preflight passed: preflight.log and checks/1793264586771687831-2.json.

  • Record-integrity checks passed: review-integrity.log and checks/1793265104284743483-2.json. Source remains unchanged; discussion-assessment.json covers every discussion key.

Limitations:

  • Local focused tests stopped before compilation because libmo.so was missing and available native artifacts failed provenance matching; fileservice-focused.log and checks/1793264666222051245-2.json record exit 1. No local Go test pass is claimed.

  • CI evidence contains statuses, not raw per-case logs. Author-reported Darwin repetition totals were not independently verified.

  • Whole-CN fault/restart recovery and performance acceptance were not independently exercised.

@Ariznawlll

Copy link
Copy Markdown
Collaborator Author

结论

本轮本地测试通过。已正常推送 40a7cc3f020aaa963190df4784271c2daebe3dcf,同步 main@b27f3869e6f2552311fbbdda2f62b0ca31ec3a67 并解决 3 处合并冲突;GitHub 回读为 MERGEABLE。这里是合并兼容性及本地回归结论,不是整套产品问题的端到端验收结论。

关键证据

  • LocalFS/LocalETLFS 保留 main 新的共享 mutable-file helper,同时为匿名 unlink 失败保留类型标记,使 spill root 仍能封禁后续创建;底层 unlink/close 错误均保留。dedup diagnostic 保留独立资源 ledger 和清零断言,也保留 main 的显式 SpillSize 限额。未修改 revision 4 设计或削弱原断言。
  • 新增回归测试:在实际文件系统构造 unlink 失败,覆盖同时 close 失败、FD 不发布且已关闭、root 封禁后不再创建文件、其他 root 仍可用。原始直接采用 raw unlink 的合并方案会在两个反例失败;保留类型标记后,新旧匿名文件相关测试连续 3 次通过。
  • Darwin/arm64、Go 1.27.1:11 个 owning package 普通单测全部通过(4,083 个通过事件、7 项环境/opt-in 跳过未计入通过);fileservice/dedupjoin 定向 race 连跑 3 次,192 个通过事件、无失败。相关包 go vet、make err-check、gofmt/diff 检查通过;当前源码原生构建及 provenance 校验通过。
  • 本 PR 与 fix(spill): retain cleanup ownership across removal errors #30099(f25faa6e0120fa517299e35f1cf2f530e49af955)使用不同的正常 merge commit,但内容树完全相同:76488aa544c44698350a676ea4167b3ca33cb891。以上本地执行在 f25faa6 工作树完成,复用的是同一内容树的验证结果,未声称独立重复跑了两遍。这两条仍是同一整合实现,不是独立的两个修复。

待解决点

推送触发的自动 CI 正在运行,尚未声明全部通过;仍需相关 reviewer 复审原有 CHANGES_REQUESTED。真实 SQL/BVT、Linux 运行时、整 CN 故障/重启恢复与性能验收未在本机执行。本轮未手动触发 CI、部署或共享环境测试,未 force push、合并/关闭 PR、approve、dismiss review 或解决评论线程。

@XuPeng-SH

XuPeng-SH commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 080249fa56041598a7ab7b6471343bf229fc4885

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: 080249fa56041598a7ab7b6471343bf229fc4885

Assessment: request_changes

The approved cleanup design reuses existing owners and budget tokens with bounded lease/fence state. One integration defect remains: bundled CNs share LOCAL, so the new lease prevents the second CN from initializing. This newly traced consumer changes the earlier approval.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

  • P1 cmd/mo-service/main.go:936: Start the documented launch-multi-cn or launch-with-proxy manifest. Both CN configurations explicitly use LOCAL data-dir mo-data/local2.
    Impact: The first CN holds the exclusive scratch lease; the second returns ErrSpillRootOwned and aborts cluster startup. Isolate these CNs' scratch roots, for example through distinct LOCAL directories, and add a two-CN initialization regression while retaining lease exclusion.
    Evidence: Both layouts' cn1.toml and cn2.toml share the LOCAL path. launch.go:156-181 starts them in one process; config.go:629-641 preserves explicit directories. The production-initializer probe reproduced second-CN rejection in both layouts; changing only its LOCAL directory allowed both initializations. Evidence: probe_multicn_startup_v1_test.go, multicn-startup-probe-v1.jsonl and checks/1794226807962642118-4.json.

Validation:

  • Reviewed all 38 changed files, 24 discussion entries and four linked issues. The approved design blob matches its record; discussion-assessment.json covers every discussion key once.

  • Isolation preflight passed. Native prerequisites matched 198 current inputs and 34 output hashes.

  • All 11 owning packages passed normally; nine passed full race runs. validation-summary.json maps successful package results to command receipts and logs.

  • Six exact concurrency tests passed 486 adaptive race repetitions. The WINDOW cancellation/reuse test passed atomic coverage.

  • Whitespace, changed-file gofmt and make err-check passed. Final audit verified the frozen head, clean source and receipt/log correspondence: checks/1794227079976444278-5.json.

Limitations:

  • Full GROUP and HashJoin race runs hit the 300-second limit; remaining recovery was interrupted after the startup blocker converged. No full race pass is claimed for those packages.

  • The initializer probe used private paths and MEM non-LOCAL stores. Whole-CN boot/restart, production fault injection and performance validation were not run. Supplied compose CI success does not cover this single-process shared-LOCAL topology.

@mergify

mergify Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request

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

Re-review of 080249fa56041598a7ab7b6471343bf229fc4885.

The old shared-queue/lifecycle design blocker is resolved by the explicitly approved revision-4 local lifetime contract. Anonymous descriptors are not published until unlink succeeds. Named producers, handoffs, rejected payloads, popped buckets and terminal consumers retain one effective destruction owner. Failed removal fences further creation and conservatively abandons the shared disk token without retaining the ended query.

Q1 ownership and Q3 bounded retained state close; Q2 fenced admission remains independent of blocked cleanup. OS syscall completion deadlines are explicitly outside the accepted contract, not newly claimed here. No remaining code blocker found.

Supplementary Linux CPU validation at this head passed: focused root/message/budget checks; terminal cleanup regressions in message plus six colexec consumer packages; 100 repetitions of TestSpillRootFencedAdmissionDoesNotWaitForCleanup under race; and one short race run of fileservice, message and process. Prior source-qualified author evidence is reused for unchanged boundaries. This is not a fresh SQL/BVT, whole-CN restart, performance or hosted-CI acceptance claim.

@XuPeng-SH

XuPeng-SH commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 735ef35cb59009edffe9d437eef2cffbafe09f88

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: 735ef35cb59009edffe9d437eef2cffbafe09f88

Assessment: request_changes

The previously reported multi-CN startup failure remains open, and spill cleanup now strips structured retry error codes. The accepted synchronous cleanup and root-fencing design reuses existing reservation ownership and avoids a background retry queue, but its lease must coexist with supported launch configurations.

Model: gpt-6.1-terra / max

Session: 01a212e9-10a4-7203-9194-162fe0e55042 · slot 0 · generation 13

  • P1 cmd/mo-service/main.go:361: Start either bundled two-CN launch configuration. Both CNs use the same LOCAL directory, and each now acquires an exclusive spill-root lease during initialization.
    Impact: The second CN fails initialization with “spill scratch root has another live owner,” so the bundled multi-CN and proxy launch configurations cannot start. This occurs before any query spills.
    Evidence: The existing concern in reviews:5825840033 remains reproducible. The current initializer probe fails for both shared-LOCAL layouts and passes with isolated roots; a separate DISK-V2 lease probe reproduces the same result. See review-probes.log and diskv2-probe.log. Give concurrent CNs distinct scratch roots while retaining exclusive cleanup ownership.

  • P2 pkg/sql/colexec/spillutil/join_spill.go:1709: A probe child or join-key evaluation returns a structured MatrixOne error while a spilled join scatters its probe input, even when every writer closes successfully.
    Impact: errors.Join wraps the primary error even when cleanup returns nil. MatrixOne’s retry and pipeline serialization paths require a direct *moerr.Error, so a retryable RC error is no longer retried and is serialized as a generic internal error.
    Evidence: The focused scatter probe returns *errors.joinError; moerr.IsMoErrCode rejects the retry code, and pipeline serialization changes code 20628 to 20101. See review-probes.log, pkg/common/moerr/error.go:990 and pkg/pb/pipeline/pipeline.go:108. Preserve the primary error when cleanup succeeds, and preserve appropriate MatrixOne classification when reporting simultaneous cleanup failures.

Validation:

  • Private-runtime preflight passed; receipt checks/1795625651030704744-2.json and preflight.log.

  • Reused the earlier native build after matching 195 tracked native inputs; see native-inputs.log and checks/1795625688088712794-2.json.

  • Selected cleanup and ownership tests passed across ten packages; see targeted-tests.log and checks/1795626129771710461-2.json.

  • Focused race tests passed for root fencing, lease shutdown, concurrent close and abandoned reservations; see race-tests.log and checks/1795626471558492078-2.json.

  • Selected process, window and frontend spill-consumer tests passed; see consumer-tests.log and checks/1795626701308556696-2.json.

  • The initializer and retry-identity probes failed as described; see review-probes.log and checks/1795625901532458547-2.json. The DISK-V2 lease probe also reproduced the shared-root failure with an isolated-root control; see diskv2-probe.log and checks/1795626831806007238-2.json.

Limitations:

  • The full DISK-V2 initializer repeat timed out before producing test output; the narrower DISK-V2 lease probe completed. No full cluster launch or end-to-end SQL retry was run.

  • Author-reported Darwin validation did not include matching retained receipts in the supplied local validation evidence.

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/documentation Improvements or additions to documentation kind/test-ci size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

7 participants