You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: CLONE and DATA BRANCH cannot use a table created earlier in the same transaction #26113
CREATE TABLE ... CLONE and DATA BRANCH CREATE TABLE cannot use a table
created earlier in the same explicit transaction as their source, even though
ordinary queries in that transaction can read the new table.
Tested version
main at 2eb7f523e5a10f352d3e258183ed8440510388de
Reproduction
DROPDATABASE IF EXISTS g4d_tx_repro;
CREATEDATABASEg4d_tx_repro;
USE g4d_tx_repro;
CREATETABLEsrc(id INTPRIMARY KEY, v VARCHAR(20));
INSERT INTO src VALUES (1, 'a');
BEGIN;
DATA BRANCH CREATE TABLE c1 FROM src;
-- This succeeds and returns 1, so c1 is visible in the transaction.SELECTCOUNT(*) FROM c1;
-- This fails although c1 is visible above.
DATA BRANCH CREATE TABLE c2 FROMg4d_tx_repro.c1;
ROLLBACK;
The same problem is visible in the underlying clone path:
Both variants were repeated three times with fresh databases.
Actual result
The first table is readable, but the second create fails:
c1_visible
1
ERROR 1064 (HY000): SQL parser error: table g4d_tx_repro-c1 does not exist
The rollback removes the first table and leaves no branch metadata from the
transaction.
Expected result
The second clone/branch create should resolve the table created earlier in the
same transaction, consistently with ordinary query visibility. Both tables
should commit or roll back together.
Code analysis
dataBranchCreateTable delegates to handleCloneTable. Without an explicit
snapshot, handleCloneTable creates an MO_TS hint using tryToIncreaseTxnPhysicalTS and calls BackgroundExec.ExecRestore.
The restore source lookup reads the catalog at that timestamp and does not
include the transaction's newly created source table, while an ordinary query
through the shared transaction can already read it. The source-resolution path
therefore has different read-your-own-DDL semantics from the surrounding
transaction.
Additional checks
Two independent DATA BRANCH CREATE TABLE statements in one transaction
succeed and create two metadata/snapshot records.
The failure also occurs with a fully qualified source table name.
reason: this changes explicit-transaction visibility plus persisted Data Branch ancestry/protection metadata and later DIFF behavior.
production_entrypoint: CREATE TABLE ... CLONE, ... COPY GRANTS, and DATA BRANCH CREATE TABLE/DIFF through one client transaction.
automated_terminal_coverage: the authenticated embedded regression covers raw CLONE, COPY GRANTS, three-level branch chains, exact committed lineage/protect snapshots, dropped intermediate and zero-history LCA DIFF in both directions, and rollback cleanup; test/distributed/cases/git4data/clone/clone_can_rollback.sql also passed exact-head BVT.
remaining_validation: deployed Proxy + multi-CN verification of the same transaction, catalog, privilege, and cleanup terminals.
Merge evidence:
PR final head: 5bf795867c2a23c13aff1b2f366f10f96353564a
Please verify on a deployed Proxy + multi-CN environment, using one connection:
Retain an autocommit control and an explicit named-snapshot control.
Inside BEGIN, build multi-level raw CLONE, COPY GRANTS, and Data Branch chains from objects created earlier in that transaction; verify read-your-own-DDL and grant visibility.
Commit, then verify exact mo_branch_metadata ancestry and one matching branch-protect snapshot per live branch. Drop an intermediate ancestor and verify direct, deep, sibling-LCA, unchanged, mutated, and reverse DIFF results.
Repeat the construction with ROLLBACK; verify no created tables, copied privileges, branch metadata, or branch snapshots remain.
Pass: all statements and DIFF counts are correct, persisted ancestry/protection metadata is exact, and rollback leaves no state. Fail: source/grant lookup error, incorrect DIFF, missing/duplicate metadata or snapshots, or any rollback leak.
在显式事务中创建源表 base,先执行 DATA BRANCH CREATE TABLE first_branch FROM base,再在同一事务中以 first_branch 为源创建 second_branch。这覆盖了原问题的“前一个 Data Branch 创建的表在同一事务内不可见”路径。
Activity
fix: preserve transaction visibility for table clone (#26293)
VioletQwQ-0 commentedon Jul 31, 2026
Post-merge QA handoff for PR #26293.
QA Decision
CREATE TABLE ... CLONE,... COPY GRANTS, andDATA BRANCH CREATE TABLE/DIFFthrough one client transaction.test/distributed/cases/git4data/clone/clone_can_rollback.sqlalso passed exact-head BVT.Merge evidence:
5bf795867c2a23c13aff1b2f366f10f96353564a0a3e5a46faa92d2add7f925d084ebc929adadc07mainat preparation):d510c8c3c475d5255e2e31c5a53b4a079054533d; test current or newermain.Please verify on a deployed Proxy + multi-CN environment, using one connection:
BEGIN, build multi-level raw CLONE, COPY GRANTS, and Data Branch chains from objects created earlier in that transaction; verify read-your-own-DDL and grant visibility.mo_branch_metadataancestry and one matching branch-protect snapshot per live branch. Drop an intermediate ancestor and verify direct, deep, sibling-LCA, unchanged, mutated, and reverse DIFF results.ROLLBACK; verify no created tables, copied privileges, branch metadata, or branch snapshots remain.Pass: all statements and DIFF counts are correct, persisted ancestry/protection metadata is exact, and rollback leaves no state. Fail: source/grant lookup error, incorrect DIFF, missing/duplicate metadata or snapshots, or any rollback leak.
Ariznawlll commentedon Aug 1, 2026
测试版本
main15a2d07c687a62a0984cf62846b092912a28c0f1原问题验证
在一个显式事务内,先创建源表,再创建 raw CLONE、三级 Data Branch 和
COPY GRANTSCLONE。连续 3 轮提交后,五个对象均可读到两行;三级 branch lineage 元数据完整,且COPY GRANTS的 SELECT 授权存在。Happy Path 覆盖
COPY GRANTS。DATA BRANCH DIFF可识别一处变化;删除中间分支后,深层分支与源表 DIFF 仍正确为 0。Unhappy Path 覆盖
COPY GRANTS路径执行ROLLBACK。mo_tables中不存在四个新对象,未泄漏表、branch 元数据或授权。白盒验证
回归测试
测试证据
PASS 26113_transaction_visibility_clone_branch_copy_grants_and_rollback_cleanup。测试结论
测试通过。
Ariznawlll commentedon Aug 1, 2026
测试版本
main15a2d07c687a62a0984cf62846b092912a28c0f1原问题验证
在显式事务中创建源表
base,先执行DATA BRANCH CREATE TABLE first_branch FROM base,再在同一事务中以first_branch为源创建second_branch。这覆盖了原问题的“前一个 Data Branch 创建的表在同一事务内不可见”路径。本次新增黑盒回归连续执行 3 轮,每轮 47 条语句/断言,3/3 均成功;与 #26111、#26070 共用的回归用例总计 141 条语句/断言成功。
Happy Path 覆盖
nested_visible=1,证明首个 Data Branch 创建的表在该事务内可作为后续源表。Unhappy Path 覆盖
ROLLBACK,检查mo_catalog.mo_tables;first_branch与second_branch的计数为 0。白盒验证
未增加独立故障注入。此问题是公开事务 SQL 的可观察行为,黑盒用例直接验证事务内可见性及 rollback 清理;不以内部 mock 替代实际 catalog 与事务路径。
回归测试
已加入 motr 黑盒回归:PR #74,测试文件:issue_26113_26111_26070_branch_integrity.test。
测试证据
执行命令:
./motr --config /tmp/motr-git4data-fulltext-blackbox-config.yml --repeat 3 --do-test 'issue_(26144|26113)' -v。其中本用例 3 轮均为success,共141/141条语句/断言成功;对应回归提交:8f0f759。测试结论
测试通过。
fix: preserve transaction visibility for table clone (matrixorigin#26293
fix: preserve transaction visibility for table clone (matrixorigin#26293
fix: preserve transaction visibility for table clone (matrixorigin#26293