Repository navigation
Description
Is there an existing issue for the same bug?
- I searched open and closed issues for publication/subscription,
__mo_index_secondary,ResolveIndexTableByRef, and secondary-index lookup failures.
Branch Name
4.1-dev / 4.2-dev (production confirmation on v4.2.1; code-path confirmation on v4.1.4)
Commit ID
- v4.2.1 production build:
d2393868a7aaa6343518d80849fe4696aa3577e9 - v4.1.4 tag:
a185c23b375956afe098320baf8df39000a43936
Other Environment Information
- Production topology: distributed, multiple CNs.
- The report is anonymized; no customer/account identifiers or credentials are included.
- The same failure was recorded on two distinct CN UUIDs, excluding a single-CN cache anomaly.
Actual Behavior
A subscriber can scan a published table, but a predicate fails when the optimizer selects a regular secondary index:
ERROR 1146 (HY000): no such table publisher_db.__mo_index_secondary_<uuid>
Observed counterfactual on v4.2.1:
COUNT(*)on the subscribed table succeeds.- Adding a predicate that selects secondary index A fails with the hidden-table error.
- Ignoring index A causes the plan to select secondary index B, which fails with the same error for B's hidden table.
- Ignoring all regular secondary indexes succeeds and returns the expected base-table result.
- The referenced hidden index tables exist in the publisher database catalog.
The resolver reconstructs an incomplete subscription context:
subMeta = &plan.SubscriptionMeta{
AccountId: ref.PubInfo.TenantId,
}getRelation then replaces the valid publisher database with the empty subMeta.DbName, so the hidden index table cannot be resolved.
The same missing-DbName code is present in v4.1.4 and v4.2.1. This is therefore an existing 4.1/4.2 defect, not a newly introduced 4.2 regression. Runtime production evidence is currently from v4.2.1; v4.1.4 reachability is confirmed from the identical resolver path and still needs an isolated SQL reproduction.
Expected Behavior
Queries through a subscription must resolve planner-selected hidden index tables using the publisher account and publisher database derived from trusted ObjectRef.PubInfo metadata. A subscriber query should return the same authorized rows whether the optimizer chooses a base-table scan or a regular secondary-index scan.
Steps to Reproduce
-- Publisher account (sys)
CREATE DATABASE publisher_db;
CREATE TABLE publisher_db.events (
id BIGINT PRIMARY KEY,
event_type VARCHAR(64),
created_at BIGINT,
KEY idx_event_type(event_type),
KEY idx_created_at(created_at)
);
INSERT INTO publisher_db.events VALUES
(1, 'login_success', 1),
(2, 'other', 2);
CREATE ACCOUNT subscriber ADMIN_NAME 'admin' IDENTIFIED BY '<password>';
CREATE PUBLICATION events_pub DATABASE publisher_db ACCOUNT subscriber;Close the publisher connection and open a separate client as the subscriber account:
mysql -h <host> -P <port> -u 'subscriber:admin' -pThe remaining statements must run in that subscriber session, not in sys:
CREATE DATABASE subscribed_db FROM sys PUBLICATION events_pub;
-- Base-table path succeeds.
SELECT COUNT(*) FROM subscribed_db.events;
-- When the optimizer selects idx_event_type, this can fail with
-- no such table publisher_db.__mo_index_secondary_<uuid>.
SELECT COUNT(*)
FROM subscribed_db.events
WHERE event_type = 'login_success';
-- Bypassing all secondary indexes succeeds.
SELECT COUNT(*)
FROM subscribed_db.events
IGNORE INDEX (idx_event_type, idx_created_at)
WHERE event_type = 'login_success';Use enough rows/statistics so that the natural predicate selects the secondary-index path. Do not use FORCE INDEX as the sole witness on 4.2: the affected build can silently fall back to a base-table scan. Confirm index selection with EXPLAIN.
Additional information
-
Related issue [Bug]: pub+fulltext index,can not use select * from where match() against() #20210 covers publication + FULLTEXT and the same broader publisher-context family, but the present failure uses ordinary secondary indexes and ordinary predicates.
-
Main PR fix: support fulltext scans over publications #26702 includes the exact missing field:
DbName: ref.SchemaName,
Main contains this fix; v4.1.4, v4.2.1, and the inspected 4.1/4.2 development branches do not.
-
[Bug]: SHOW INDEX and JDBC key metadata are empty for subscription tables #27759 is distinct: it concerns empty
SHOW INDEX/JDBC metadata for subscriptions, while this issue is query execution failure after the optimizer selects a hidden index table. -
No base-data loss or physical hidden-index loss was observed. Recreating indexes or subscriptions is not an appropriate first response.
Suggested validation for the 4.1/4.2 fix:
- Reproduce the indexed predicate failure on an exact unpatched build.
- Backport the scoped
DbName: ref.SchemaNamefix from fix: support fulltext scans over publications #26702. - Prove the same query succeeds without
IGNORE INDEXand returns a typed/multiset-equal result to the base-table path. - Add regular secondary-index publication/subscription BVT coverage, including different subscription aliases, two indexes, multiple CNs, revoke/drop, and unpublished-object denial.
Activity
gouhongshen commentedon Sep 6, 2026
Investigation and regression coverage for this issue are complete.
Findings:
a185c23b375956afe098320baf8df39000a43936) and v4.2.1 tag (d2393868a7aaa6343518d80849fe4696aa3577e9) both reconstructSubscriptionMetawithAccountIdbut omitDbNameinTxnCompilerContext.ResolveIndexTableByRef.getRelationusesSubscriptionMeta.DbNamewhen resolving the hidden secondary-index relation. The empty database name causes the planner-selected__mo_index_secondary_<uuid>table lookup to fail, while the base-table path can still succeed.mainalready contains the production lineDbName: ref.SchemaNamethrough merged PR fix: support fulltext scans over publications #26702. No additional production fallback or duplicate resolver logic is needed in this branch.Regression proof:
TestResolveIndexTableByRefUsesPublisherDatabaserequires the publisher database name, publisher tenant context, hidden-index relation, and returnedObjectRef. Removing the existingDbName: ref.SchemaNameline temporarily made this test fail because the database argument became empty; the line was restored before commit.pub_sub_secondary_indexBVT uses 100,000 rows and two regular secondary indexes. It verifies naturalEXPLAINselection of both indexes, expected indexed results, base-table andIGNORE INDEXcontrols, separate subscriber aliases/accounts, table-publication access boundaries, membership revoke/restore, publication removal, prepared statements, and cleanup.54/54with a 100% success rate; the focused UT and full./pkg/frontendpackage also passed.Draft PR: #28284
The PR is intentionally test/CI-only because the production correction is already present on
main; release branches without that line still need their scoped backport and normal release validation.gouhongshen commentedon Sep 6, 2026
PR #28284 is trying to fix this issue.
test: cover secondary indexes in publication subscriptions (#28284)
gouhongshen commentedon Sep 6, 2026
PR #28284 has merged and is awaiting manual validation. The issue remains open.
[4.2] fix: resolve secondary indexes in subscriptions (#28280)
Ariznawlll commentedon Sep 17, 2026
测试版本
main8e8e1998ef02b1f6233ddb1c2d3208f3b70d2d83原问题验证
使用发布账户与订阅账户构建 100,000 行带普通索引的发布表,在订阅侧验证索引可用性。按
event_type和created_at的查询计划均出现Index Table Scan;订阅表、强制基础表扫描控制查询和 prepare 查询的计数结果一致。Happy Path 覆盖
覆盖多账户 publication/subscription、100K 数据、两种索引谓词、EXPLAIN 与 prepared statement。
Unhappy Path 覆盖
不适用:该 issue 的验收目标是订阅侧索引可见、可选且结果正确;同时验证测试结束后完整清理发布、订阅和账户资源。
白盒验证
通过
EXPLAIN检查Index Table Scan,并以IGNORE INDEX的基础表扫描结果作为对照。回归测试
已加入 MOTR PR #181:
issue_28279_subscription_secondary_indexes.py。本地连续 3 轮通过。测试证据
motr --repeat 3 08_multitenant_rbac.issue_28279_subscription_secondary_indexes:3/3 通过,跨账户索引计划和结果对照均一致。测试结论
测试通过。
test: cover secondary indexes in publication subscriptions (matrixori…
test: cover secondary indexes in publication subscriptions (matrixori…
test: cover secondary indexes in publication subscriptions (matrixori…