Repository navigation
Description
Confirmed behavior
An unfiltered DELETE against a session temporary table fails with error 20706 when another transaction holds the shared SNAPSHOT lifecycle gate. A row-scoped DELETE should not enter persistent-table replacement/branch-lineage admission merely because it deletes every row.
This is distinct from #28255 (temporary CREATE/DROP rollback semantics) and #29814 (public persistent-table TRUNCATE). Do not weaken the general retained-lock FastFail protection to address this case.
Versions and evidence
- Exact Main nightly MO
cd8d5abf9665a97d13e50b04840fb74b877fd339, image digestsha256:d554cbb460dc128049b329fb0e1d5e2e9c35d9a559cb2986d732b37e3a970b04. - Main nightly, MOTR
issue_28255_temp_ddl_rollback.test: the first failure isdelete from create_rollback, not CREATE and not snapshot restore. - Loki namespace
mo-main-family-38268423576-1, podnightly-regression-dis-tp-cn-nvqjf, 2026-10-12 20:33:45.649 UTC: transaction74150f0a772e8ef818ddd22a558484d9, table 272477,Exclusive-Row-FastFail, errorlock options conflict, wait policy is fast fail. - Independently reproduced on Shanghai50 with the exact immutable image, fresh single-CN/TN/LogService, 4 CPU / 8 GiB. No concurrent workload is needed other than the explicit gate holder below. The no-holder control succeeds and rollback restores row 2.
- Current Main
175a645a85994f2c95992d3aa8d6dacb6d9e167fstill has the same relevant planning/admission code; this is source verification, not yet a second binary test.
Deterministic minimal reproduction
Use a disposable instance. Connection A:
CREATE DATABASE temp_delete_probe;
USE temp_delete_probe;
CREATE TEMPORARY TABLE t(id INT PRIMARY KEY);
INSERT INTO t VALUES(2);
BEGIN;
UPDATE t SET id=4;Connection B (hold open after the SELECT returns):
BEGIN;
SELECT feature_code FROM mo_catalog.mo_feature_registry
WHERE feature_code='SNAPSHOT' FOR SHARE;Then A:
DELETE FROM t; -- actual: ERROR 20706, FastFail
ROLLBACK;
SELECT * FROM t; -- row 2 survivesRollback B and remove the probe database. Holding this catalog row is only a deterministic test substitute for another admitted lifecycle operation; this is not a proposed customer workaround.
Root cause
Both modern and legacy DELETE planning still permit temporary tables to use the truncate implementation. The legacy makeOneDeletePlan puts TableDef.Name (the physical temporary relation name) into TruncateTable.Table. Runtime Scope.TruncateTable identifies temporary tables through the session's logical alias lookup. That lookup misses the physical name; the statement enters persistent-table broad lifecycle admission and tries to acquire an exclusive global SNAPSHOT gate after the earlier UPDATE retained data locks. Admission intentionally FastFails rather than creating a reverse-order wait.
The safety check is doing its job; the incorrect input path is temporary DML being lowered to persistent lifecycle replacement. A scoped fix should keep temporary DELETE as transactional row DML, including its index maintenance, and leave public TRUNCATE and permanent-table optimization unchanged.
Required validation
- Temporary unfiltered DELETE succeeds while the unrelated shared gate is held, without waiting for its release; rollback and commit produce independently expected rows.
- Binary/text parameter handling is irrelevant to the reproduction.
- Temporary tables with a secondary index and a same-name permanent table remain isolated; deletion updates only the temp table/index and preserves rollback.
- Both planner paths reject temporary truncate lowering; permanent-table truncate eligibility is unchanged.
- No claim of permanent data loss is made by this report.
Activity
fix(sql): admit view replacement before database locks (#30092)
fix(plan): keep temporary DELETE on transactional row path (#30091)
XuPeng-SH commentedon Oct 16, 2026
转测 @Ariznawlll。
已在 main 提交
0723ae37b1183a03bac9eda16669dfc7e474dfb8对关联修复 #30091 完成本 issue 对应的定向验证,所测场景通过。已运行对应功能回归;本轮测试结果支持进入测试验收。
测试入口:
TestGossipFixtureConfigPortRangeTestGossipFixtureStartupConfigurationFailureTestTemporaryDeleteDoesNotRewriteToTruncateTestIssue30089TemporaryDeleteAvoidsPersistentLifecycle请在目标验收版本复核后决定关闭;本次转测保留 issue 为 OPEN。
Ariznawlll commentedon Oct 19, 2026
测试版本
maindef799e1260dd547cae2e0e54323ea20ec1b768594da0308ad0c5d4fb1d9912293339218bf26dfa3经祖先检查确认进入上述 main。原问题验证
按 issue 的顺序在临时表会话中先
UPDATE并保持事务,另一会话SELECT feature_code ... WHERE feature_code='SNAPSHOT' FOR SHARE持有生命周期共享锁,然后执行无条件DELETE FROM临时表。修复后的实际结果是 DELETE 成功,无旧版的 20706 FastFail。MOTR 同 CN 双会话该路径 10/10 轮通过;仓库内嵌双 CN 的TestIssue30089TemporaryDeleteAvoidsPersistentLifecycle10/10 轮通过。Happy Path 覆盖
(5,40)成功;回滚后查询实际恢复为(2,20)。v=20,查询实际为(3,20);另一会话同名普通表仍为(99,99)。Unhappy Path 覆盖
(2,20)和唯一索引可用性恢复;同名普通表未被误删。每轮测试均删除独立数据库,未观察到测试对象残留。白盒验证
pkg/tests/issues/issue_30089_test.go的真实 SQL 双 CN 测试在上述 main-count=10通过,-race -count=3通过;均包含原始共享锁屏障、带/不带索引临时表、回滚和同名普通表隔离。回归测试
1b3adcaa6fd2a37981334ea56018c9acc0151854;本地定向 3/3、额外时序 10/10、相邻三用例 3/3。测试证据
10 pass/ 230 条 SQL 无错误;Go 普通 10/10、race 3/3。测试结论
测试通过。