Skip to content

[Bug]: subscription tables invisible to DATA BRANCH (CREATE SNAPSHOT/DIFF report 'table does not exist') #30949

Closed

Description

@Ariznawlll

Description

Tables in a subscription database are visible to ordinary queries and SHOW TABLES / information_schema, but are invisible to the DATA BRANCH machinery: CREATE SNAPSHOT ... FOR TABLE and DATA BRANCH DIFF on a subscription table fail with "table does not exist" / "no such table". The subscriber can read the data but cannot snapshot, diff, or branch it.

Environment

  • MatrixOne dev build 3a1e42b430, server reports 8.0.30-MatrixOne-v1.3.0

Reproduction

-- publisher (tenant_a): CREATE PUBLICATION pub1 DATABASE tdb ACCOUNT tenant_b;
-- subscriber (tenant_b):
CREATE DATABASE sub3 FROM tenant_a PUBLICATION pub1;

SELECT COUNT(*) FROM sub3.t1;          -- OK: 3
SHOW TABLES FROM sub3;                 -- OK: t1, t2
SELECT table_name FROM information_schema.tables WHERE table_schema='sub3';  -- OK (t1, t2)

CREATE SNAPSHOT sp FOR TABLE sub3 t1;  -- ERROR 20101: table sub3.t1 does not exist
DATA BRANCH DIFF sub3.t1 AGAINST sub3.t1;  -- ERROR 1146: no such table sub3.t1

Root cause

The subscription table is resolvable through the SQL query path and the catalog (so SELECT/SHOW/information_schema work), but the DATA BRANCH snapshot/object layer resolves tables through a different path that does not see subscription tables. This is the DATA BRANCH-side residue of the same subscription-table visibility gap that #27794 reported for information_schema (now fixed there); the snapshot/branch path was not covered by that fix.

Impact

  • A subscriber cannot build snapshots or run DATA BRANCH DIFF/MERGE/PICK against subscribed data — a natural "branch the subscribed dataset and track changes" workflow is blocked.
  • Inconsistent visibility: the same table exists for reads but "does not exist" for branching, which is confusing and breaks tooling that mixes the two.

Expected behavior

Subscription tables should be resolvable by the DATA BRANCH snapshot/diff path just like locally-created tables (CREATE SNAPSHOT and DATA BRANCH DIFF should work on them), or the limitation should be a clear, documented error rather than "table does not exist".

Activity

  1. added
    kind/bug
    on Oct 23, 2026
  2. added this to the MO-202610 milestone on Oct 23, 2026
  3. added theissue type on Oct 23, 2026
  4. added
    severity/s0
    ai-easy
    and removed on Oct 23, 2026
  5. gouhongshen commented on Oct 24, 2026

    @gouhongshen
    Contributor

    PR #31039 is trying to fix this issue.

  6. gouhongshen commented on Oct 25, 2026

    @gouhongshen
    Contributor

    PR #31039 has merged and is awaiting manual validation. The issue remains open.

  7. iamlinjunhong commented on Oct 25, 2026

    @iamlinjunhong
    Contributor

    Additional post-merge evidence: subscription CLONE loses its logical source during a planner retry.

    PR #29152, exact head 9807498ef2a7c814c411490073e9217fab2c1159, failed the Linux/x64 Compose + Pessimistic BVT in run 40186991579, attempt 1, job 121151741645. publication_subscription/pub_sub_data_branch.sql:266 fails on:

    data branch create table c1 from sub3.t1;
    -- SQL parser error: table tdb-t1 does not exist

    The following four failures are consequences of missing c1; the next independent c2 clone succeeds. The BVT summary is 49,990 statements, 5 failed. Coverage job 121160943227 is blocked by its producer prerequisite and calculates no coverage verdict.

    The uploaded CN trace identifies the trigger, rather than merely a matching filename. On cn-0 at 11:32:36.422596 UTC, compile/lifecycle_fk_scope.go:563 reports txn need retry in rc mode, def changed; the same transaction then resolves physical database tdb under subscriber account 64 and plan/build_table_clone.go:93 emits the missing-table error. Transaction: 72f65f5cca73bdec18e1c14907118e2a. Reports artifact.

    buildCloneTable rewrites stmt.SrcTable from the subscription alias to the publisher's physical table. Replanning the same AST can therefore lose the subscription routing. This code, its table-clone admission path, and its relation/subscription resolver are unchanged by PR #29152; the PR's edits to clone execution concern database cloning of Python routines.

    A controlled planner probe reproduces this exact mechanism on both the PR and current official main 12eeeb0205b5e87faef48660ddbcd8cb5e18baea:

    1. Parse CREATE TABLE ldb.c1 CLONE sub3.t1; resolve the subscription to publisher tdb.t1; require the entire first BuildPlan to succeed.
    2. Observe that the AST source now contains tdb.
    3. Build the same AST again under subscriber identity: exact SQL parser error: table tdb-t1 does not exist.
    4. Parse the identical original SQL afresh: the complete plan succeeds again.

    Both diagnostic runs passed their positive and negative assertions (PR 0.881s, main 0.853s). Main was compiled via a read-only Go overlay in the existing task checkout: all 6,698 main Go files were byte-checked against Git, both sides of renames were handled, PR additions were hidden, and module/native inputs were unchanged. Mode: Go 1.27.1, Darwin/arm64, controlled CGo wrapper. This is a planner reproduction using exact main sources, not a separate Linux BVT replay or prior maintainer confirmation.

    This identifies a B6 clone-retry residue distinct from the original snapshot/DIFF lookup gap. Preserve the logical alias across planning/retry when investigating a fix. No unrelated source changes were made in PR #29152. The same run also ended with a separate SQL integration flush timeout that is still being attributed, so no workflow rerun has been requested yet.

  8. Ariznawlll commented on Oct 26, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:官方 matrixorigin/matrixone main。
    • commit:5153053e6f2698403b425eb8c52ff06af21995d9;执行时远端 main 指向同一 SHA,修复 PR fix(frontend): resolve subscription tables for DATA BRANCH and snapshots #31039 的 merge commit ecd2581d9d896cd071231b2dca3721986ff5753f 已核实为其祖先。
    • 部署方式:隔离本地服务,1 LogService + 1 TN + 1 CN,由该 SHA 编译的 mo-service;SELECT git_version() 返回上述完整 SHA。二进制 SHA-256:d3a72022b0c53cd2ce8eded638fd0f09f7080bb34e8395d2ffe10fe2f10f9707。
    • 测试日期:2026-10-26。

    原问题验证

    针对 issue 中“订阅表普通查询可见,但 CREATE SNAPSHOT / DATA BRANCH DIFF 报表不存在”的原始路径,建立发布方和订阅方两个独立账号,发布 qa49_db(t1 三行、t2 一行),在订阅方建立 qa49_sub。每轮均重新建账号与表、执行、销毁;连续 3/3 通过:订阅方 SELECT count(*) FROM qa49_sub.t1 实际为 3,SHOW TABLES 与 information_schema.tables 均实际返回 t1,t2;CREATE SNAPSHOT qa49_sp FOR TABLE qa49_sub t1 成功,发布方快照记录的真实归属为发布账号、qa49_db.t1;DATA BRANCH DIFF qa49_sub.t1 AGAINST qa49_sub.t1 返回空结果,未再报表不存在。发布方插入 (4,'d') 后,以该快照对当前 t1 做 DIFF,实际仅返回一条 INSERT,4,'d'。

    Happy Path 覆盖

    1. 订阅读取、表枚举、系统表枚举与快照建立均 3/3 成功;快照正确绑定发布方物理对象,而非错误写入订阅方 catalog。
    2. 快照前后三行/四行边界的差分仅包含新增 id=4,订阅表自比较差分保持空集;3/3 一致。
    3. 每轮通过订阅方的显式 DROP SNAPSHOT ... FROM <发布方> PUBLICATION ... 清理;发布方快照记录查询实际返回空集。发布、订阅库及账号也逐轮清理,无清理错误。

    Unhappy Path 覆盖

    1. 向订阅表作为目标执行 DATA BRANCH MERGE、PICK,均被明确拒绝为 cannot perform ... into subscription database;拒绝后发布方 t1 仍精确为 (1,'a'),(2,'b'),(3,'c'),(4,'d'),订阅方本地源表仍精确为前三行,3/3 无部分写入。
    2. 对订阅库不存在的表创建快照得到 does not exist;发布方 catalog 中对应快照记录仍为空,3/3 无残留元数据。

    白盒验证

    修复涉及的订阅操作数分类、写目标拒绝、发布快照绑定、快照创建准入四项定向 Go 测试,在本次官方 main 上以 go test -race ./pkg/frontend -run '^(TestClassifySubscriptionOperandCoversVisibilityModel|TestRejectSubscriptionBranchWriteDestinationCoversC5|TestSnapshotPublicationBindingResolution|TestDoCreateSnapshotPublicationAdmission)$' -count=3 执行:ok github.com/matrixorigin/matrixone/pkg/frontend 4.209s,四项均 3/3 通过,未检出数据竞争。

    回归测试

    公共 SQL 原路径及异常路径已加入 MOTR #278 的 issue_30949_subscription_branch.py 与配对输出;定向运行 3/3 通过。该 PR 当前仍 OPEN,四项离线检查均通过;未声称 MOTR 全量运行/合入。没有向 MatrixOne 仓库新提回归 PR。

    测试证据

    • 本轮隔离部署的三轮输出依次为 count=3, snapshot owner=q49p1/q49p2/q49p3, diff=INSERT id4, write rejection atomic;实际执行脚本保留于本地隔离测试目录。服务已正常关闭,测试端口已释放。
    • 修复 PR #31039 已 MERGED,且其合入提交在上述官方 main 祖先链中。该 PR 的 Compose/Pessimistic BVT 等部分检查为通过,但 CI Required、UT/SCA 等检查显示失败/阻断;不能据此宣称完整 CI 通过,也未运行全量 suite。原始行为的独立本地 SQL 3/3 与上述定向回归是本结论依据。
    • 与本 issue 原始 SNAPSHOT/DIFF 可见性不同,CLONE 在同一 AST 重规划时丢失订阅逻辑别名的残留,已在上述官方 main 以原始 SQL 重解析成功作对照、同一 AST 重规划失败的方式复现 3/3,并单独记录为 #31194;本评论不将该残留视作已修复,也不以其代替本 issue 原路径结论。

    测试结论

    测试通过。

  9. gouhongshen commented on Oct 29, 2026

    @gouhongshen
    Contributor

    Reproduction record for a transient recurrence of the same symptom in the B6 regression case this fix added:

    • Run/job: MatrixOne ALL CI, run 40798664858 attempt 1, job "Matrixone Compose CI execution / multi cn e2e bvt test docker compose(PROXY)" (123204520182), terminal 2026-10-29T01:47:33Z; head 8b41e39227 of PR #30988.
    • Observed: test/distributed/cases/publication_subscription/pub_sub_data_branch.sql failed 5/324 — all five at the same instant (01:41:28Z, con id=2, tenant_b), chain-rooted at row 266 data branch create table c1 from sub3.t1; returning SQL parser error: table tdb-t1 does not exist (the resolveBranchCloneSource parse-shaped diagnostic after a nil resolve of the publisher-side source), with rows 268/269/270/271 failing as its cascade. The jobs' remaining 50756 statements — including the same file's other 319 assertions and the full workspace-DML suites — passed in the same run.
    • Why unrelated to PR fix(disttae): bound long-transaction workspace maintenance and close orphan-cleanup ownership #30988: the immediately preceding run 40778977585 (head 7c75f3e07b) passed this whole PROXY job, and the only delta to the failed head is commit 8b41e39 confined to pkg/vm/engine/disttae admission bookkeeping — none of the frontend/data-branch/subscription resolution bytes differ between the green and the red run. A single transient resolve miss during the run's compose load cascaded into the 5 statement failures; the B6 lineage regression (fix fix(frontend): resolve subscription tables for DATA BRANCH and snapshots #31039) is this issue's own coverage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-easykind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions