Skip to content

[Bug]: pubsub modules disagree on SHOW ... WHERE support #31385

Closed

Description

@Ariznawlll

DRAFT 9 (SDK, 2026-10-27) — candidate issue, not yet filed

Title: [Bug]: pubsub API is internally inconsistent on SHOW WHERE support and get_publication() fetches every publication on each call

Description

Two related defects in PubSubManager (pubsub.py):

1. Inconsistent assumptions about SHOW ... WHERE support

  • get_publication() / list_publications() (line ~316) hard-code SHOW PUBLICATIONS with the docstring/comment "SHOW PUBLICATIONS does not support WHERE clause, so filtering is done client-side" — the whole publication list is fetched and filtered in Python.
  • list_subscriptions() (line ~452) builds SHOW SUBSCRIPTIONS WHERE pub_account = '...' AND pub_database = '...' with server-side WHERE.

If the server truly does not support WHERE on SHOW statements, then list_subscriptions with filters emits an always-failing query on every call (users would see "SQL syntax error" when filtering subscriptions — masked as PubSubError("Failed to list subscriptions: ...")); if the server does support WHERE on SHOW SUBSCRIPTIONS, the comment about PUBLICATIONS is stale and get_publication needlessly round-trips every publication. Either way the module contradicts itself — and given both commands share the SHOW grammar family in the parser, one of the two code paths is wrong on any given server build.

2. get_publication(name) scans the entire publication list every call

SHOW PUBLICATIONS        -- full result, then python `for row: if row[0] == name`

Worse, it is the return-path of create_database_publication()/create_table_publication(): after creating, they call self.get_publication(name) — so creating one publication costs a full listing scan plus one; on accounts with many publications this multiplies; and when the fresh publication is (unexpectedly) not visible yet in SHOW (metadata propagation lag), the create path throws Publication 'name' not found even though creation just succeeded — the SDK reports a failure for a successful operation and the caller cannot distinguish.

Reproduction

pub = client.pubsub.create_database_publication("p1", "db1", "acc2")
# execute: CREATE PUBLICATION ... ; SHOW PUBLICATIONS; python-scan for 'p1'
# if SHOW lags at all → PubSubError "Publication 'p1' not found" (but the publication exists)

client.pubsub.list_subscriptions(pub_account="acc1")
# emits: SHOW SUBSCRIPTIONS WHERE pub_account = 'acc1'   — per the module's own comment
#        SHOW cannot take WHERE → error, if that comment reflects server behavior

Impact

  • Any account publishing a handful or more publications pays O(N) per API call, each create doing the extra scan.
  • The false-failure report on creation (visible-lag window) breaks provisioning automation: retry loops will attempt CREATE again and hit "publication already exists" — turning a refresh race into a confusing double error.
  • If WHERE-on-SHOW is unsupported, every filtered list_subscriptions breaks; if supported, the publication path is just inefficient. Both states were shipped as one consistent module, so one half is broken/suboptimal by construction.

Expected behavior

  1. Decide based on actual server grammar (SHOW PUBLICATIONS/SUBSCRIPTIONS where-clause parse test): either support WHERE on both (file a server-side gap if missing) or filter client-side on both — consistency is the ask.
  2. create_*_publication should return a Publication object built from the construction arguments (the SDK knows name/database/table/account already) — no post-create lookup needed; or retry the SHOW briefly before reporting "not found".
  3. get_publication(name) should use a targeted query if the server grows SHOW PUBLICATIONS WHERE name = ...; meanwhile at least avoid hiding SQL errors from the filtered subscriptions path.

Activity

  1. added
    kind/bug
    on Oct 27, 2026
  2. added this to the MO-202610 milestone on Oct 27, 2026
  3. added theissue type on Oct 27, 2026
  4. Ariznawlll commented on Oct 27, 2026

    @Ariznawlll
    CollaboratorAuthor

    Update after re-checking current main (2026-10-27): the inconsistency half of this report is RESOLVED — list_subscriptions now uses plain SHOW SUBSCRIPTIONS with the comment "SHOW SUBSCRIPTIONS doesn't support WHERE clause", consistent with the publications path (both client-side filter now). Remaining valid half: get_publication(name) still does a full SHOW PUBLICATIONS + python scan on every call, and create_*_publication still re-reads via get_publication after creating (visible-lag window reports failure for a successful create). Keeping open for those two; the WHERE contradiction can be dropped from scope.

  5. added a commit that references this issue on Oct 30, 2026
    bbfe556
  6. XuPeng-SH commented on Oct 30, 2026

    @XuPeng-SH
    Contributor

    QA handoff for merged #31774 (main bbfe55669a1440424914d45a283a1d0e36f722fa): please verify publication lookup and post-create visibility/error reporting. This isolated QA run inspected the issue and merged source but did not run tests or a live MatrixOne service at this SHA because resource headroom under the existing guard was insufficient. Earlier QA counterexamples and PR author-reported validation remain scoped to their recorded versions and are not results of this QA run.

  7. Ariznawlll commented on Oct 30, 2026

    @Ariznawlll
    CollaboratorAuthor

    结论

    测试通过。同步 SDK 的 publication 读取优先使用目标名称查询;创建已成功但元数据回读失败时,异常明确标记创建已确认。

    关键证据

    • 官方 main@d39d8a40343ccd40bf665036388df7a40ee867f8;修复 PR fix(python): unify SDK query and analytics lifecycle contracts #31774 的合并提交 bbfe55669a1440424914d45a283a1d0e36f722fa 位于祖先链;实际二进制和 SDK 同完整 SHA。本地隔离 1 CN / 1 TN / 1 LogService,Python 3.12。
    • 三个独立库均实际创建数据库级和表级 publication,成功读取;对普通名称的 get_publication 抓取到一条 SHOW PUBLICATIONS ILIKE 定向语句,不是全表读取。
    • 对数据库级和表级创建分别在 SDK 元数据回读处模拟异常,异常均带 statement_acknowledged=True 和 phase=metadata_readback;撤销模拟后真实服务均可读到已创建的 publication。每轮清理测试 publication 和库。
    • 新增 MOTR #295 定向 3/3 通过、0 skipped。

    待解决点

    • 模拟的是 SDK 本地回读异常,不是网络分区或多 CN 延迟;本轮未覆盖异步管理器和大规模 publication 性能,也未运行完整 MOTR suite。Add build constraint to assembly source files #295 尚未合入,SDK 场景需显式启用和匹配源码,默认 SKIP 不计通过;特殊名称的兼容回退仍可能读取完整列表。
  8. Ariznawlll commented on Oct 30, 2026

    @Ariznawlll
    CollaboratorAuthor

    回归位置更正:#295 已关闭并汇总至 MOTR #298,该 issue 的定向用例已包含在 #298。此前测试证据与未覆盖项不变;#298 尚未合入,完整 MOTR suite 未运行。

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

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions