Repository navigation
Description
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-codeSHOW PUBLICATIONSwith 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) buildsSHOW 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 behaviorImpact
- Any account publishing a handful or more publications pays O(N) per API call, each
createdoing 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_subscriptionsbreaks; 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
- 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.
create_*_publicationshould return aPublicationobject 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".get_publication(name)should use a targeted query if the server growsSHOW PUBLICATIONS WHERE name = ...; meanwhile at least avoid hiding SQL errors from the filtered subscriptions path.
Activity
Ariznawlll commentedon Oct 27, 2026
Update after re-checking current main (2026-10-27): the inconsistency half of this report is RESOLVED — list_subscriptions now uses plain
SHOW SUBSCRIPTIONSwith 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.fix(python): unify SDK query and analytics lifecycle contracts (#31774)
XuPeng-SH commentedon Oct 30, 2026
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.Ariznawlll commentedon Oct 30, 2026
结论
测试通过。同步 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。SHOW PUBLICATIONS ILIKE定向语句,不是全表读取。statement_acknowledged=True和phase=metadata_readback;撤销模拟后真实服务均可读到已创建的 publication。每轮清理测试 publication 和库。待解决点
Ariznawlll commentedon Oct 30, 2026
回归位置更正:#295 已关闭并汇总至 MOTR #298,该 issue 的定向用例已包含在 #298。此前测试证据与未覆盖项不变;#298 尚未合入,完整 MOTR suite 未运行。