Skip to content

fix(plan): keep temporary DELETE on transactional row path - #30091

Merged
XuPeng-SH merged 11 commits into
matrixorigin:mainfrom
LeftHandCold:fix/30089-temporary-delete-lifecycle
Oct 15, 2026
Merged

XuPeng-SH merged 11 commits into
matrixorigin:mainfrom
LeftHandCold:fix/30089-temporary-delete-lifecycle

Conversation

@LeftHandCold

@LeftHandCold LeftHandCold 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:

issue #30089

What this PR does / why we need it:

Fixes #30089. Keep unrestricted DELETE on a session temporary table as transactional row DML instead of lowering it to persistent-table TRUNCATE lifecycle admission.

  • Exclude temporary targets in both modern and legacy planner eligibility checks.
  • Keep legacy temporary index maintenance aligned with base-table DELETE.
  • Preserve permanent-table TRUNCATE optimization, public TRUNCATE, and retained-lock FastFail protection.

@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 结论:PASS,未发现本次修改引入的阻断问题。注意这是代码审查结论,不是 CI 全绿或允许绕过合并门禁。当前审查账号与 PR 作者同为 LeftHandCold,GitHub 不允许自我 APPROVE,因此以 COMMENT 记录。

范围:HEAD 2f897d7;获取的 main / base / merge-base 为 21f19ae。完整审查 4 个文件的全部改动,并结合 #30089 的复现、两套 planner、临时表解析、索引维护和 runtime TRUNCATE 的入口核对。属于聚焦 bug fix,不需要新状态机或重大设计文档。

设计与正确性:

  • 责任放在 DELETE→TRUNCATE 的既有准入判断处是合适的:modern planner 拒绝临时表重写;legacy 的主表和索引两处同时排除临时表,避免只删主表却跳过隐藏索引。
  • 保留 isUnrestrictedDelete 的语义分类;只是禁止临时表物理替换,没有误把全删当成带过滤条件的 DELETE,也未改动永久表的 eligibility、显式 TRUNCATE 或 retained-lock FastFail。
  • TxnCompilerContext.Resolve 为会话别名/已拥有的物理临时表设置 IsTemporary;索引通过现有 ResolveIndexTableByRef 解析。modern 路径维护各索引的 UpdateCtx;legacy 路径保留已有隐藏索引全扫描及 row-delete,最终 CanTruncate=false,不能再进入 Scope.TruncateTable 的持久生命周期门禁。
  • 新测试复用已有两 CN fixture,用另一个真实事务持有 SNAPSHOT shared gate,DELETE 必须在 holder 释放前成功;检查 rollback 的固定行值、提交后唯一键复用、同名永久表不受影响。没有依赖 sleep 或概率调度。

Unhappy-path / 性能审计:

维度 结论
Q1 归属/清理 生产代码复用原有行 DML 的事务/索引所有权;测试在获取连接、事务后安排 Close/Rollback,临时表和数据库有清理,未新增后台资源。
Q2 等待 未修改锁协议或添加等待/重试;DELETE 不再错误申请全局生命周期独占锁。测试有 2 分钟总上下文、10 秒 DELETE 和 20 秒清理上下文。
Q3 增长/性能 没有新缓存、队列或状态机;但大临时表无条件 DELETE 由物理替换变为数据量相关的扫描、行删除和索引维护,会增加时间及事务资源成本。接受 PR 已披露的这项正确性取舍,不将其表述为性能无损;永久表不受新增条件影响。

证据(复用并核验当前精确 HEAD,未在本地重复启动 MO 集群):

  • Ubuntu/x86 UT job:确认 checkout 为上述 HEAD,Go 1.27.1 / linux amd64。下载该 run 的 ut-diagnostics artifact,核对 JSON 终态和 checkpoint:pkg/sql/plan 8/8 race 分片 status=0;TestTemporaryDeleteDoesNotRewriteToTruncate 两个子场景均 PASS,0.01s。
  • 同一报告中 TestIssue30089TemporaryDeleteAvoidsPersistentLifecycle PASS,1.77s;indexed_false / indexed_true 均 PASS;pkg/tests/issues 分片终态均 PASS。报告文件有裁剪标记,上述结论只引用仍在 artifact 中的明确终态,不以裁剪内容推断其他测试。
  • 两项现有真实 BVT checks(Compose PROXY、PESSIMISTIC)为 SUCCESS;新增场景的 public-path 证据来自上面的真实 SQL 集成测试,而非单靠 mock/EXPLAIN。
  • 本地 gofmt 检查四个变更文件和 git diff --check 均通过。没有既有人工 review thread 待闭环。

CI 限制:整体仍 FAILURE。UT 与 coverage 日志均指向 pkg/logservice/gossip_fixture_test.go:130 的 randomPorts.allocate(probeTestPort),实际签名需要 (int, int, func(int) error);SCA 日志也报告这一编译错误。已核对调用/定义文件在本 PR HEAD 与 base 的 blob 完全一致,这是源码层面的归属证据;没有额外重跑完整 clean-base CI,也不宣称 SCA 其他输出已经全部分类。应单独修复该编译阻塞并重新验证 CI,不能靠本次代码 PASS 将红色门禁当作通过。

@LeftHandCold

Copy link
Copy Markdown
Collaborator Author

已修复这轮 CI 的共同编译阻断,保留本 PR 原有 SQL 修复与全部测试门禁。

根因不是本 PR 的 SQL 专项失败:Main 的 #30029 引入 Gossip fixture 调用后,#29978 将 randomPorts.allocate 改为 (first, limit, probe),但遗漏了该调用点。SCA、UT 和 UT Coverage 都报 gossip_fixture_test.go:130: not enough arguments;Coverage 汇总因缺少 UT profile 随后失败。干净 Main 21f19ae063 和原 PR head 上已复现同一编译错误。

最小修复仅改一个测试文件:先获取现有 testPortRange(),错误直接返回,再把合法范围传给分配器。新增两节点配置检查,确认六个端口不重复且在允许范围内。不改生产服务端口、原有锁逻辑、重试上限或 CI 门禁。

本地验证(50,Linux/amd64,Go 1.27.1):

  • Gossip fixture 全部定向测试通过,含真实端口冲突、失败清理和重建。
  • Logservice 全包 -short -tags=matrixone_test 通过(196.285s)。
  • 新端口检查 race 100 次通过;六节点 Gossip 收敛/重启 race 6 次通过。
  • 完整仓库 molint 成功、golangci-lint v2.14.0 零问题;另核对另一 PR 的不同包也零问题。
  • 临时 DELETE planner 专项通过;视图替换真实双 CN 专项再次通过。原远端 UT 中两个 PR 各自的 SQL 集成专项、构建和 BVT 本来也已通过。

同一修复已同步 #30091 和 #30092。推送会触发完整 CI;本地验证不冒充新的远端 ARM64 SCA/完整覆盖率已绿,最终以新一轮 CI 结果为准。

@mergify mergify Bot added the queued label Oct 14, 2026
@mergify

mergify Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-14 07:13 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🚫 Left the queue — 2026-10-14 07:13 UTC · at 95bf977a132e8db3f5be460f8807251c4b50bd40

This pull request spent 10 seconds in the queue, with no time running CI.

Reason

The pull request can't be updated

GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/iceberg-connector.yml without workflows permission
GitHub only lets Mergify write to .github/workflows/ with the workflows permission. An organization owner can accept Mergify's pending permissions at https://dashboard.mergify.com/orgs/matrixorigin/repositories.

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Requeued — the merge queue status continues in this comment ↓.

@mergify mergify Bot removed the queued label Oct 14, 2026
XuPeng-SH added a commit that referenced this pull request Oct 14, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Related to #25267.

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

PR and issue bodies submitted through CLI/API can miss repository
template fields or use headings and line endings incompatible with
description consumers. Add a shared GitHub delivery reference to
`mo-dev` and `mo-self-review` that checks current templates and body
encoding before publication, then verifies the stored body afterward.

The guidance requires a real, relevant issue reference, preserves author
content and intentional code escapes, covers required issue-form fields,
and distinguishes a rendering failure from an unverified CRLF
hypothesis. Both skills link to the same contract and keep publication
checks in the appropriate phase.

Validation:
- Both skills pass `skill-creator` validation; shared-reference links
resolve.
- Executed the documented normalization example against BOM/mixed line
endings, Unicode, literal code escapes, LF idempotence, empty input, and
invalid UTF-8.
- Complete diff review and `git diff --check` pass.

This is agent guidance; the CRLF root-cause hypothesis for #30091
remains unverified.

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

Deep review of exact head 95bf977a132e8db3f5be460f8807251c4b50bd40, base/merge-base 0a8a28f7582ab530c9672994c6d13cf4d976c0be: APPROVE. No actionable blocker found.

Reviewed every hunk in all five changed files, both historical reviews, all conversation comments, the complete #30089 reproduction, and the empty inline/thread history. This is a focused eligibility repair, not a major design-gated refactor. I independently checked both planner paths, compiler dispatch, session temporary/physical-name resolution, hidden-index resolution and maintenance, and existing TRUNCATE/lifecycle admission.

The modern eligibility guard and both legacy guards coherently exclude temporary targets. Legacy index deletion can no longer be skipped while the base table uses row deletion. Permanent-table eligibility, explicit TRUNCATE, and retained-lock FastFail are unchanged; the compiler selects existing row DML rather than persistent replacement. No new production ownership, goroutine, retry, cache or wait edge is introduced. The port-range addition is test-only, uses the existing bounded allocator and closes runtime registrations, including partial-configuration failure.

Independent validation in a detached exact-head worktree, CGO enabled with the canonical wrapper's verified matching primary native artifacts:

  • Full planner normal package: PASS, 16.564s; full logservice normal package with -short: PASS, 195.744s.
  • Full planner -race: PASS, 58.631s; twelve Gossip fixture roots / 43 named results under -race: PASS, 96.035s. Planner has two existing skips (cosine_similarity and resetInterval); they are not counted as passes.
  • New planner eligibility and Gossip port-range roots each separately passed -race -count=100; measured T=0, B=30s, hence N=100.
  • Committed authenticated two-CN temporary DELETE regression passed two normal rounds. Its exact -race measurement passed at T=7.43s; adaptive N=floor(30/7.43)=4 repetitions all passed (package 15.373s). Indexed/unindexed rollback, committed key reuse and same-name permanent isolation remained asserted.
  • An additional temporary native probe passed twice on one physical session using real prepared/binary DELETE, a unique index plus a secondary index, duplicate NULL keys, UPDATE followed by DELETE behind a held SNAPSHOT reader, rollback restoration, explicit-transaction commit/key reuse, and public temporary TRUNCATE. The permanent same-name row remained 99. Probe was removed after validation; tracked source and diff whitespace are clean.

Temporary unrestricted DELETE now costs row scanning/deletion and index maintenance; this correctness tradeoff is accepted, not described as performance-neutral. No large-table benchmark or full nightly run was performed.

Exact-head build, Ubuntu UT, ARM64 SCA, coverage, PROXY and PESSIMISTIC BVT checks are successful. The Mergify queue rule failure is separately explained by its workflow-write permission error; it is not a product-test failure. This approval does not bypass merge protections or authorize permission changes.

@mergify

mergify Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-15 14:40 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-15 16:27 UTC · at 1f2e98ceffc817741eec916c03e5b178bd9d0bf1

This pull request spent 1 hour 47 minutes 2 seconds in the queue, with no time running CI.

Reason

Pull request #30091 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

This branch was successfully deployed

1 active deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Temporary-table DELETE enters persistent lifecycle admission and fails behind unrelated SNAPSHOT readers

4 participants