Skip to content

fix: resolve async index lock contention during catalog teardown - #31076

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/fix-31074-31063-async-ddl
Oct 25, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/fix-31074-31063-async-ddl

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

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

Which issue(s) this PR fixes:

issue #31074 — Closes #31074
issue #31063 — Closes #31063
issue #31065 — Closes #31065
issue #31075 — Closes #31075

What this PR does / why we need it:

Async index initialization can conflict with account teardown, and periodic watermark publication can deadlock against database retirement. Branch-index readiness also needed to cover the actual writes, while the snapshot fixture consumed a second deadline before bootstrap.

  • Keep one standalone account-drop transaction owner. Retry nested database FastFail only after nonblocking proof of successful abort cleanup for the captured generation. Preserve the target account ID, rebuild attempt-local work, and exclude borrowed transactions, uncertain commits and postcommit replay. Limit to five attempts with cancellable backoff.
  • Make periodic watermark writes use the existing FastFail option, whole-batch transaction/reservation rollback and next flush tick.
  • Wait for complete FULLTEXT2 results and an HNSW index plan; preserve indexed/exact-distance, branch-diff and failed-job assertions. Temporarily shorten the existing cluster-wide freshness cadence and verify restoration.
  • Reuse EnginePack's bounded lifetime after bootstrap, immediately register cleanup, and give rollback a separate cancellation-independent bound. Preserve all snapshot/merge/rollback scenarios.
  • Incorporate test: stabilize branch index readiness and snapshot fixture lifetime #31072. Rebase the three original patches onto main 1732bb3297f598bc9a90a41b8c5e4c9557cf0e9c; stable patch IDs and the 28-file PR delta are unchanged. Resulting head: d4917342ad2496d455d8265a46172c861a0ca2dd.

Ordinary SELECT/DML gains no additional SQL, transaction or polling. Persistent contention can exhaust the bounded account retry or defer watermark publication. The temporary 1s cache ticker produces a freshness sweep every fourth tick plus housekeeping; no throughput benchmark is claimed.

Validation on the rebased head

Linux amd64, Go 1.27.1 / clang 19.1.7, CPU build. New main changes ISCP initialization and internal session/temporary-table access, so affected runtime and SCA checks were rerun.

  • Owning/consumer race: full frontend, iscp, txn/client, vm/process, vectorindex/sqlexec, sql/compile suites pass: 4,888 top-level passes, one existing in-test skip (TestRuleCacheDoubleCheckLocking). No test exclusion or short mode. Includes same-generation cleanup, watermark rollback/retry, session lending/masking, clone allocator context restoration and executor reuse.
  • Targeted race: 14 roots across integration/multicn, engine tests, planner and table functions pass. Covers real async DROP contention, session owner/attacker isolation with background index maintenance and teardown, all snapshot roots, temporary-access controls and long physical identities.
  • Independent CN processes: B warms both old index generations before A's writes. B logs stale decisions and generation-change evictions, then HNSW reloads from two to three rows. Fulltext returns 1,3; indexed and independent distance results are 3,2; branch diff=2 and failed jobs=0. Convergence 5.303 s. Settings restore on both CNs, B's active ticker resets, catalog/job teardown succeeds and both processes exit normally.
  • Exact original BVT: normal mo-tester comparison on the same surviving process pair 27/27, zero failed/ignored/abnormal. Previously validated timeout/recovery, constructor FailNow/cancellation and adaptive stress controls are reused where their mechanisms are unchanged.
  • SCA/build: standard vet, custom molint and configured incremental lint pass across the 11-package affected/consumer closure. Configured lint has zero issues; all 27 custom diagnostics match unchanged base functions/files. New service binary identifies this head with vcs.modified=false; matching native provenance, formatting and diff checks verified.
  • Required gpt-6.1-sol / xhigh rebase design: 01a17315-1bcd-7552-9b24-30c103344318. Final overall review PASS: session 01a17327-06ae-7852-880a-22a23bf8dd08; no unresolved material blocker.

Commands, source fingerprints, terminal receipts and raw evidence are retained outside tracked source at /home/xupeng/.codex/issue-to-pr/matrixone/31076/rebase/ (validation-audit.json, remote-proof-audit.json, integration-audit.json).

Rebased-head GitHub CI results are not yet verified; local checks do not claim green merge CI. No merge or GPU validation is claimed.

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

@XuPeng-SH

XuPeng-SH commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: 509a3f01d9478d07712412313fd6954baccf1b72

Review completed. Read the assessment.

@mergify mergify Bot added the kind/bug Something isn't working label Oct 25, 2026
@matrix-meow matrix-meow added the size/XL Denotes a PR that changes [1000, 1999] lines label Oct 25, 2026

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

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: 509a3f01d9478d07712412313fd6954baccf1b72

Assessment: approve

Reviewed the complete 24-file delta and affected callers. The design preserves one transaction owner, permits retries only after successful same-generation abort cleanup, and makes periodic watermark publication yield through the existing batch rollback path. No actionable defects remain.

Model: gpt-6-astra / xhigh

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

Validation:

  • Reconciled 30 checks with commands, source fingerprints, exit receipts and retained logs in /home/xupeng/.local/state/mo-bot/jobs/2041135aa7c575f5c35e0055/attempt-1/validation-audit.json. Source remained unchanged; native provenance and 192 matching build inputs were verified.

  • Full txn/client and iscp suites passed normally and under race detection. Frontend runs had only the unchanged export fixture's read-only-filesystem failure; that test passed under race detection from a writable diagnostic directory.

  • Both two-CN regressions passed normally and under race detection. Rollback-fence controls passed. Adaptive race repetitions passed for 15 boundary/lifecycle tests at 100 repetitions each and the watermark regression at two repetitions.

  • Base-production overlays reproduced account-drop error 20706 and watermark deadlock behavior, establishing that the regression tests distinguish the fixes.

  • Formatting, diff checks, standard vet and incremental lint completed; golangci-lint reported zero issues. All 18 custom-vet diagnostics were verified against unchanged base code.

Limitations:

  • Frozen CI was pending or skipped. Author-reported runs lacked retained receipts, and linked issue bodies were absent; assessment uses the supplied behavioral contracts and independently retained checks.

  • No throughput benchmark was run. Source tracing found no additional SQL or transaction work on ordinary SELECT/DML paths. Sustained contention can still exhaust bounded account retries or defer watermark publication.

@XuPeng-SH

XuPeng-SH commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: 69fa7e5f7c3cce0b8eb1872a3dfd5125992d0e6c

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

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: 69fa7e5f7c3cce0b8eb1872a3dfd5125992d0e6c

Assessment: request_changes

Reviewed the complete 28-file delta and relevant owners/callers. The production design is coherent: account deletion has one transaction owner, replay requires proven aborted cleanup, and watermark contention reuses existing rollback and scheduling. No confirmed implementation defect was found. One explicitly retained validation requirement remains: convergence of an independently cached remote reader.

Model: gpt-6-astra / xhigh

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

  • P2 test/distributed/cases/git4data/branch/edge/branch_multi_index_restore_init.sql:45: Validation requirement: a reader on CN B already caches an older FULLTEXT2/HNSW generation while initialization or CDC writes occur on CN A.
    Impact: The new cluster-wide freshness cadence and bounded readiness waits are intended to handle this condition, but current evidence does not demonstrate it. Successful local reads can depend on local invalidation and therefore do not establish closure of the remote-cache failure.
    Evidence: The frozen PR explicitly retains stale-reader validation; local_validation is empty and its referenced author bundle is absent. The exact branch case passed twice locally, but those runs used one CN. The two-CN regressions exercise lock contention, and embedded CNs share process-global vectorindex/cache.Cache. The SQL also does not force remote cache prewarming. Before approval, provide matching evidence from independent CN processes: prewarm the reader, perform writes/initialization elsewhere, verify complete FULLTEXT2 results and the HNSW plan/result oracle within the waits, then verify cadence restoration and teardown. Retain source identities, commands, reports and service logs. This is an evidence requirement, not an observed production defect.

Validation:

  • Evidence and receipt reconciliation is retained in /home/xupeng/.local/state/mo-bot/jobs/efa207c0cdffa3e5dcbdfc51/attempt-1/validation-audit.json; final audit receipt checks/1792926951066939302-4.json exited 0. Detailed design and coverage notes are in review-notes.md.

  • Confirmed exact head/base, unchanged source, formatting and diff checks. Isolation preflight passed; repository native provenance verification matched 192 build/native inputs. Go checks used assigned caches and the supplied test executor.

  • Sixteen focused tests across five packages passed normally and under race, including real two-CN async DROP contention, watermark batch rollback/retry, transaction cleanup boundaries and all nine snapshot scenario roots.

  • Owning frontend, txn/client and iscp race checks passed: 3049 top-level passes and one existing in-test skip. Test_openNewFile_nilCtx was explicitly excluded because it writes into the read-only source directory.

  • The exact branch SQL/result pair passed actual mo-tester normal comparison twice on one CN: 27/27 each, with teardown verified between runs.

  • A forced FULLTEXT2 expectation mismatch timed out as intended: exactly one failure, 26 successes including cadence restoration, verified teardown, and a subsequent exact case passing 27/27.

  • Constructor FailNow probes intentionally exited 1. Separate race-enabled verification cells confirmed transaction abort, canceled pack context, removed engine directory and successful subsequent fixture construction for live and canceled work contexts.

  • Reconciled 30 referenced historical receipts and log hashes without treating old-head execution as combined-head validation. Superseded diagnostic setup failures and the corrected audit-script error remain separately recorded.

Limitations:

  • Frozen CI was pending; CI was not rerun. Full normal owning-package suites, repeated stress and the configured full linter were not rerun on the combined head.

  • No throughput benchmark was performed. Source analysis confines added production work to bounded account-conflict replay and periodic watermark statement options; ordinary SELECT/DML gains no additional SQL or polling path.

  • Standalone linked issue bodies were not supplied. Their contracts were assessed from the frozen PR description, source and supplied comments. Independent remote-cache validation remains open as described above.

Wait for the complete FULLTEXT2 result and HNSW index plan instead of
storage rows that can predate the last branch write. Use the existing
freshness cadence control during this serial BVT and check both its
application and restoration across CNs.

Preserve the result, plan, branch diff, and failed-job assertions while
removing obsolete readiness variables and prepared statements.

Validated with single-CN and separate-process two-CN BVT runs, a warm
remote-cache challenge, and a timeout/cleanup negative control.
@XuPeng-SH

XuPeng-SH commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: d4917342ad2496d455d8265a46172c861a0ca2dd

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

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

Assessment: approve

Reviewed the complete 28-file delta and affected owners/callers. The design preserves one account-drop transaction owner, requires successful same-generation abort cleanup before replay, and reuses existing watermark rollback and scheduling. Snapshot cleanup and public index-readiness assertions retain their behavioral coverage. Independently verified remote-reader evidence closes the previous validation requirement. No actionable findings remain.

Model: gpt-6-astra / xhigh

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

Validation:

  • Reconciled seven exact-head author receipts against commands, source hashes, tree identity, exit status and retained logs. Six full race suites recorded 4,888 top-level passes and one existing in-test skip; targeted integration checks recorded 14 top-level passes.

  • Verified 136 remote-proof artifact hashes and the exact-head service binary. Independent CN B cached older generations before CN A wrote; both cache entries subsequently became stale and were evicted. FULLTEXT2 and HNSW results converged in 5.303 seconds, with independent distance, branch-diff and failed-job assertions passing.

  • The exact SQL/result pair passed normal mo-tester comparison: 27/27, zero failed, ignored or abnormal statements. Verified cadence restoration, catalog/job teardown and graceful exit of both service processes.

  • Verified native provenance through the repository build owner, formatting and diff checks, standard vet and configured incremental lint. All 27 custom-analyzer diagnostics match unchanged base functions/files. Reconciled retained timeout, constructor-cleanup and adaptive-stress controls for unchanged mechanisms.

  • Review receipts and logs are indexed in /home/xupeng/.local/state/mo-bot/jobs/28a78e8f30da665617cc9e9a/attempt-1/review-check-index.json. Detailed evidence and scope are retained in validation-audit.json, supplemental-audit.json and review-notes.txt. Source remained unchanged.

Limitations:

  • Runtime validation was reused from matching retained evidence; this session ran evidence, provenance and static audits. Frozen CI remained pending or skipped for material jobs.

  • Standalone linked issue bodies were not supplied; their contracts were assessed from the frozen PR description, comments and source.

  • No throughput benchmark or GPU validation is claimed. Ordinary SELECT/DML gains no additional SQL or polling; persistent contention can exhaust bounded account retries or defer watermark publication.

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

审查结论:APPROVE。未发现本 PR 范围内可确认的 correctness、并发/生命周期、兼容性或性能回归,P0/P1/P2/P3 均为 0。

审查版本:head d4917342ad2496d455d8265a46172c861a0ca2dd,base 1732bb3297f598bc9a90a41b8c5e4c9557cf0e9c。已同步 origin/main 和 PR head,并核对完整 28 文件 diff、关联 issue #31074/#31063/#31065/#31075、历史 reviews、inline comments 和 PR conversation;这是 iamlinjunhong 的首次 review。

重点核查了独立 DROP ACCOUNT 的唯一事务所有权、同代 abort 清理证明、账号身份重读、有限重试与取消,以及借用事务、提交错误和提交后副作用的边界;沿内部 SQL executor 检查了 watermark FastFail 的传递、整批事务及 reservation 回滚和后续 tick 重试。新增测试覆盖了实际异步初始化争用、watermark 交叉行锁冲突和失败边界;快照 fixture 的事务清理先于 EnginePack 关闭,branch BVT 保留完整 FULLTEXT2 结果、HNSW 计划、独立距离结果及 branch diff/失败 job 断言。

验证:本轮执行的 git diff --check 和 Loom PR artifact check 均通过,源码未修改。派发的 30 个 checks 全部结束:14 success、14 skipped、2 neutral,无 failure;CI Required 为 success。GitHub 显示 mergeable=true、mergeable_state=behind,远端 head 与审查版本一致。本轮未运行本地 Go/BVT 测试,也未独立复跑作者报告的跨进程缓存收敛实验;运行时结论仅参考派发 CI,作者及历史 review 的实验描述不作为本轮执行结果。

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/test-ci size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

3 participants