Skip to content

fix(spill): retain cleanup ownership across removal errors - #30099

Open
Ariznawlll wants to merge 57 commits into
matrixorigin:mainfrom
Ariznawlll:codex/spill-cleanup-retry
Open

Ariznawlll wants to merge 57 commits into
matrixorigin:mainfrom
Ariznawlll:codex/spill-cleanup-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.

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.

Retry transient file removal for JOIN and GROUP spill. Preserve failed bucket and writer ownership for later cleanup, and propagate JOIN cleanup errors. Cover normal, transient, and persistent failure paths with focused tests.

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

This seems to the the wrong fix.

Spill should spill to local disk, and local file clean up should always be open, immediately delete, until close. If we want to rotate file descriptor, we add delete in the operator close time. spill clean up should not be a queue/backgroup job etc.

We do not support/use spill to remote or S3 yet. Even when spilling to S3, should be cleaned up by operator close.

The exception could be a mo-service is CRASHED/KILLED (if we rotate file descriptor). In this case, there should be a "delete all temp spill files" when CN restarts. That is it ...
queue for delete of temp file is an fragile, over design.

Resolve HashBuild Prepare conflict by retaining direct-input validation before prior-generation spill cleanup. Cover valid and invalid direct-input configurations alongside failed removal ownership.

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

Incremental review of exact head 505a1abb7acbf46080511512ca17c135638edc1f (base 9f873692e0efa869c64c4d1c84e212c5a8a3272a). The new commit changes only docs/design/spill_cleanup_owner_v1.md; it clearly records that revision 3 is a design-only response and that approval is still pending. It also explicitly says the existing #30099/#30102 implementation is not certified by this document.

The prior design gate therefore remains unresolved: the decision table still marks the process-wide capacity/tenant blast radius, four-worker/hung-I/O behavior, in-process service/root reuse, fail-closed startup/rollback, and observability/rollout as requiring owner decisions before approval. This update documents the alternative local-lifecycle direction, but it does not implement that replacement or approve the existing queue-based code in this PR. Keeping the existing CHANGES_REQUESTED gate is appropriate; this COMMENT records review of the new revision only.

Validation boundary: I inspected the exact-head commit and design text. This workspace has no MatrixOne checkout or Go toolchain, so I did not run local Go or runtime tests. The visible checks are Connector/J Pool Reset E2E (in progress) and Iceberg Connector E2E (success); neither is spill-cleanup validation. No issue changes made; related issue #30097 remains open and assigned to Ariznawlll.

@Ariznawlll

Copy link
Copy Markdown
Collaborator Author

已根据 fengttt 的反馈更新并正常推送设计响应 505a1ab:revision 3。旧 revision 2 的后台删除队列、全局 16,384-file admission 和四 worker 已明确列为被替代的提案,不再作为推荐交付方向。

替代范围收敛到本地 open → unlink → 持有 FD → close,以及必要的具名文件 operator-close 和进程退出后启动清扫。文档列出 creation/unlink 失败、pathname reopen/FD rotation、root/service replacement、错误/取消/拒绝 handoff/Reset/Free/pool release 的具体待审闭环和最小确定性验证。建议以 #30099 为最终统一实现载体,保留 #30102 不重复的 JOIN/HashBuild 反例。

本轮仅同步文档及 PR 状态,两个分支文档完全一致,UTF-8/LF 和 diff checks 通过。替代实现尚未交付、设计尚未通过,原实现 CR 保留;旧队列的 UT/CI 不作为替代方案通过证据。没有合并或关闭 PR。

@XuPeng-SH

XuPeng-SH commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 505a1abb7acbf46080511512ca17c135638edc1f

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: 505a1abb7acbf46080511512ca17c135638edc1f

Assessment: request_changes

The design gate remains open. Revision 3 supersedes the background cleanup queue, but the complete PR still delivers that implementation. Retaining spill-file ownership is necessary; the replacement lifetime and failure contracts must be settled before implementation approval.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

  • P2 docs/design/spill_cleanup_owner_v1.md:52: Merging this candidate includes the superseded queue implementation, although revision 3 explicitly says replacement design approval is pending.
    Impact: The PR introduces process-wide admission and cleanup ownership across GROUP, HashBuild and JOIN without an accepted delivery design. Close the replacement's unlink-failure, pathname/FD-rotation and service/scratch-root lifecycle decisions, obtain design approval, then align the implementation and its validation with that design.
    Evidence: Document lines 3–5 and 18–21 supersede the queue approach; lines 33–43 leave replacement failure and lifecycle decisions pending. Nevertheless, pkg/common/spillcleanup/queue.go retains the 16,384-file cap, four workers and global terminal queue (lines 29–34 and 101–112), and production spill owners still enqueue cleanup callbacks. Frozen maintainer review 5567086544 rejects background deletion; the supplied evidence contains no subsequent replacement-design approval. This is a demonstrated design-contract failure, not an allegation of an observed runtime failure.

Validation:

  • Static check passed: check-run --timeout 60 -- python3 audit_scope.py verified the exact head/base, clean source, supplied patch correspondence, diff whitespace, all 33 changed files and seven documented test anchors. Command/source/exit receipt: /home/xupeng/.local/state/mo-bot/jobs/a98c1c3174b0ef7a14157bb4/attempt-1/checks/1792771165590739152-4.json; matching retained output: scope-audit.log and scope-audit.json in the same attempt directory.

  • The frozen exact-head CI snapshot reports successful UT, SCA, coverage, shared-build, multi-CN BVT and CI Required checks. Historical coverage failures were not carried forward.

  • Static reconciliation found corresponding repairs for earlier GROUP discarded-bucket/retained-operator ownership and JOIN scatter-cleanup concerns. Detailed evidence is retained in review-audit.json.

Limitations:

  • Exhaustive implementation, test-quality and runtime approval is deferred at the design gate. The applicable mo-self-review skill states: “An upstream design/range/artifact blocker may stop downstream review.” Skill: /home/xupeng/.local/state/mo-bot/slots/0/source/.agents/skills/mo-self-review/SKILL.md.

  • No local Go/native tests or performance measurements were run. local_validation is empty; raw CI execution logs and separate linked-issue bodies were not supplied. CI statuses and source reconciliation are not claimed as independent runtime verification.

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

The approved synchronous cleanup and restart-only recovery design addresses the prior ownership, accounting, and retention concerns. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a1869d-820c-7212-9788-aecfb86a4141 · slot 0 · generation 2

Validation:

  • Reviewed the complete delta, linked issues, and all 21 discussion entries; saved review-plan.md and discussion-assessment.json.

  • Focused Linux normal and race checks passed across 11 packages: 152 passing test events per mode, without skips.

  • Six concurrency and lease tests each passed 100 race-instrumented repetitions.

  • Reused supplied successful build, UT, coverage, static-analysis, and multi-CN BVT results.

  • validation-summary.json matches retained logs to successful receipts, verifies native inputs, and confirms the frozen source is unchanged.

Limitations:

  • No local whole-CN crash/restart, SQL fault-injection, or performance campaign was run.

  • Raw CI and author-reported Darwin validation logs were not available for independent inspection.

@Ariznawlll

Copy link
Copy Markdown
Collaborator Author

结论

本轮本地测试通过。已正常推送 f25faa6e0120fa517299e35f1cf2f530e49af955,同步 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 JOIN and HashBuild cleanup ownership on errors #30102(40a7cc3f020aaa963190df4784271c2daebe3dcf)使用不同的正常 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 4, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: f25faa6e0120fa517299e35f1cf2f530e49af955

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

Assessment: approve

The approved synchronous lifecycle reuses existing cleanup owners and accounting. Root fencing, leases and terminal abandonment preserve exclusive ownership and truthful disk charges without a retry queue. Historical concerns are closed; no actionable defect remains.

Model: gpt-6.1-sol / max

Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0

Validation:

  • Reviewed all 38 changed files, affected callers, four linked issues and all 24 discussion entries; saved the review plan and discussion assessment.

  • Verified the revision-4 design artifact matches its recorded approval.

  • Runtime preflight passed. Source-extracted probes passed five roots in normal and race modes; two concurrency roots passed 100 race repetitions each, with zero failures or skips.

  • All 35 changed Go files passed syntax/format checks; git diff --check passed.

  • Reused supplied exact-head successful build, UT, SCA, coverage, proxy and multi-CN BVT statuses.

  • Reconciled receipts, logs and source provenance in validation-audit.json. The frozen checkout remains clean.

Limitations:

  • Local MatrixOne package tests did not run because compatible native prerequisites were missing; Go 1.27.1 bootstrap also timed out. Local probes used Go 1.26.6 with documented adapters.

  • CI and author evidence lacked raw logs. No local SQL fault-injection, whole-CN restart or performance run is claimed.

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

The original cleanup-owner design objection is resolved. Revision 4 has an exact-artifact approval record and the implementation replaces the process-wide retry queue with synchronous terminal-owner cleanup, sticky root fencing and exclusive startup leases. Named-file rotation is retained; unsuccessful removal does not refund surviving disk bytes or retain ended queries/callbacks.

Checked Q1 ownership, Q2 admission/control-path independence, and Q3 retained-state bounds. The accepted design does not promise an OS unlink deadline. No remaining code blocker found.

Evidence scope: I code-reviewed this head and the corresponding #30102 integration. Their common spill-owner code matches, but their complete trees differ. I reused source-qualified prior author evidence; the supplementary Linux component/race checks were executed on #30102 at 080249f, not independently on this SHA. No fresh whole-CN restart, SQL/BVT, performance acceptance or current-head CI pass is claimed.

This branch was previously deployed

1 inactive deployment
ci — 62128360 Deployed Nov 5, 2026 by Ariznawlll
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