Skip to content

[Bug]: information_schema.PARTITIONS returns no rows for non-partitioned tables (MySQL returns one row with NULL partition columns) #31927

Closed

Description

@MatrixAdventurer

问题描述

information_schema.PARTITIONS 在 MO 里只返回分区表的行,普通表一行都没有。MySQL 对每张普通表都会返回一行,PARTITION_NAME、PARTITION_METHOD 等列为 NULL,TABLE_ROWS、DATA_LENGTH 是整张表的统计值。

有的工具和脚本会按 PARTITIONS 来汇总每张表的行数或大小,或者用 PARTITION_NAME IS NULL 判断一张表是不是分区表。在 MO 上,这些查询会把普通表全部漏掉。

环境

  • 分支:main(c32e75a2,2026-10-30)
  • 对照:MySQL 8.4.9

复现步骤

create database pdb;
use pdb;
create table p (a int);
insert into p values (1), (2);
select count(*) from information_schema.partitions where table_schema = 'pdb' and table_name = 'p';
select table_name, partition_name, partition_method from information_schema.partitions where table_schema = 'pdb';

实际结果(MO)

count(*) = 0
(第二条查询返回空结果集)

期望结果(MySQL 8.4.9)

count(*) = 1
p    NULL    NULL

补充

pkg/util/sysview/predefined.go 里的 InformationSchemaPartitionsDDL,是把 __mo_visible_tables 和 mo_catalog.mo_partition_metadata、mo_catalog.mo_partition_tables 做内连接,所以没有分区元数据的表都被过滤掉了。改成 LEFT JOIN,再为普通表补上一行 NULL 分区信息,就能和 MySQL 一致;行数和大小用 mo_table_rows / mo_table_size 按主表来取。

本操作由 LW 授权的 Grok Bot 智能体执行。

Activity

  1. added
    kind/bug
    on Oct 30, 2026
  2. MatrixAdventurer commented on Oct 31, 2026

    @MatrixAdventurer
    ContributorAuthor

    分级建议:s2。系统视图兼容缺陷:information_schema.PARTITIONS 对普通表返 0 行,依赖它汇总行数/大小或用 PARTITION_NAME IS NULL 判断分区的外部工具会把普通表全部漏掉;不影响数据正确性,可用 mo_tables 等替代。模块:pkg/util/sysview(InformationSchemaPartitionsDDL)。疑似重复:未发现(旧分区视图缺陷均已关)。建议负责人:daviszhen(sysview 近期提交者)。本操作由LW授权的MOI智能体提交

  3. assigned and unassigned on Nov 4, 2026
  4. added a commit that references this issue on Nov 5, 2026
    547d2cb
  5. XuPeng-SH commented on Nov 6, 2026

    @XuPeng-SH
    Contributor

    QA 交接(main,待验证)

    PR #32197 已合入 main,merge SHA 547d2cb2de0c1e16767290e3575a468f89dabe5c。information_schema.PARTITIONS 为普通 base table 返回一行 NULL 分区信息,分区表仍按实际分区返回,统计目标分别使用主表/分区表;保留租户可见性和内部索引、分区子表、view、sequence、临时表等排除边界。既有 startup 与有界 tenant maintenance 负责持久化定义协调,存活账户错误会回滚并保留游标。

    已读取全部 issue 评论及 PR 讨论,未发现合并版本当前适用的已验证反例或未完成的本 issue 开发 follow-up。作者报告既有 CN admission/bootstrap 错误路径及原 46/46 service SQL;新审查进行了 source/SQLite/fixture 核对,未做新 MatrixOne service 或前驱迁移运行。最终 head 的 build/UT/coverage/SCA 取消,CI Required 失败,不能称为全绿。本轮只核对远端证据,没有本地实测。

    请 @Ariznawlll 复测原例、普通表唯一 NULL 行和统计值、分区表行数/统计来源,覆盖租户权限及各类排除对象;重点检查新安装、已有当前版本租户、重启/周期协调、账户删除与存活账户错误回滚。前驱升级、真实权限/临时对象和运行时修复仍需验证。转测不等于验收通过,且不自动要求 4.2 backport。

  6. Ariznawlll commented on Nov 6, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • 当前官方 main:65b721e1b93c6b9e05db2063b220e0c35916b335,包含修复 fix(sql): honor DESC column filters and ordinary table partitions #32197;新建实例为隔离 2 CN / 1 TN / 1 LogService / Proxy,三个入口 git_version() 均为此 SHA。
    • 2026-11-06 另建独立升级实例。旧二进制自报 b27f3869e6,Go 构建信息记录为 b27f3869e6f2552311fbbdda2f62b0ca31ec3a67、vcs.modified=true;因此旧版来源不是可复现的官方干净构建。升级后的二进制 git_version() 与上述官方 main 完整 SHA 一致。

    原问题验证

    当前 main 的新建实例中,普通表返回一条 PARTITION_NAME 等字段为 NULL 的记录,分区表返回实际分区记录;两个 CN 与 Proxy 各执行 3 轮通过。主库现有 BVT 三个入口各 3 轮均为 23/23。

    Happy Path 覆盖

    1. 单独验证普通表统计与 mo_table_rows / mo_table_size 的主表值一致;分区表的每个分区统计与对应物理分区表的统计一致。视图、序列、临时表和内部索引表不泄漏;每个入口各重复 3 轮。
    2. 创建两个独立租户及同名数据库,验证租户间表不可见;受限用户仅能在 information_schema.PARTITIONS 中看到有 SELECT 权限的表,访问无权表被拒绝,连接仍可用。每个入口各重复 3 轮。
    3. 旧构建中系统租户和普通租户普通表均返回 0 行;切到当前 main 后,等待维护修复完成,两者均恢复一条 NULL 分区信息,原数据保持不变。修复完成后再次重启当前 main,两个租户的视图和数据仍正确。

    Unhappy Path 覆盖

    全新隔离升级实例中,SQL 入口在启动后 4.616 秒可连接;从 4.618 秒起连续查询普通表,直到 14.397 秒仍返回 0 行,14.606 秒首次返回 1 行。共采样 47 次,SQL 已可服务但旧视图继续对外可见约 10 秒。第一套独立升级实例也观察到启动后立即为 0,随后恢复;两套均未发现数据丢失。

    白盒验证

    当前 main 的维护器定向单测重复 3 次通过,覆盖旧 PARTITIONS 定义替换、更新失败重试、事务回滚、旧定义转换、缺失/过期定义修复、账户删除及存活账户错误传播。源码默认租户维护轮询间隔为 10 秒。当前仅观察到 SQL 可访问期间旧结果持续约 10 秒,尚未断言其根因或是否符合升级对外可见性合同。

    回归测试

    修复 #32197 已带 主库现有 BVT 和维护器单测;本轮扩展用例仅在本地执行,没有提交主库测试 PR。

    测试证据

    • 三个入口 BVT:各 3 轮,每轮 23/23;租户/权限和统计来源扩展测试均为三个入口各 3 轮通过。
    • 第二套升级实例计时结果:首个连接 4.616 秒,首个正确结果 14.606 秒;日志保存在本地隔离目录 qa-upgrade2-31927/timed-upgrade.log。
    • 修复 PR 最终 head 的 build/UT/coverage/SCA 被取消,未称为 CI 全绿。

    测试结论

    测试不通过。新建实例和维护完成后的功能验证通过,但旧实例升级后存在 SQL 已开放而旧 PARTITIONS 视图仍可见的窗口;请研发确认该窗口是否符合发布/升级合同,并排查是否应在对外开放 SQL 前完成协调。旧二进制带 vcs.modified=true,建议使用干净的官方前驱构建再次复现。

  7. XuPeng-SH commented on Nov 6, 2026

    @XuPeng-SH
    Contributor

    QA 再交接(main,待验证)

    原修复 #32197(547d2cb2de0c1e16767290e3575a468f89dabe5c)的普通表 NULL 分区行、统计、租户权限及排除对象,已由前次 QA在 main 65b721e 报告通过;当时保留的研发问题是升级后 SQL 已开放、旧 PARTITIONS 定义仍可见约 10 秒,以及前驱构建带修改标记,需要确认受支持升级合同。

    新 PR #32307 已合入 main,merge SHA 606ae4fb2a94890709a2d573aaee936a27442dc3。它把 PARTITIONS 纳入系统视图启动完成检查:缺失、过期或读取错误在 SQL ingress 前由既有 startup/admission owner 处理,必要协调失败不开放入口;移除原周期性 CN 维修循环。新增的启动回归覆盖旧定义只替换一次,以及读取/替换错误时禁止 ingress。该范围直接回应旧 QA 窗口,不能继续把旧版本反例视为新修复的当前反例。完整 3 条 issue 评论和返回的全部 PR 讨论已读,未见其他未完成的本 issue 开发 follow-up。

    证据与限制:

    • 作者报告重基于 bfbb2645c034 后 bootstrap/sysview race 分别 84/43 个顶层测试通过,覆盖 PARTITIONS 缺失/过期/错误及 admission;真实本地 catalog 的旧 4.2.8 定义触发一次协调、第二次为 no-op。
    • 作者报告用重新构建的重基二进制完成真实 released 4.2.5、单 CN/双租户的停止升级及干净重启,系统与租户 TABLES/COLUMNS/PARTITIONS 均为当前定义,普通索引表可见、物理索引隐藏,数据/有效授权保留。这是作者报告,不是本轮实测,也不是实际多 CN release 升级结论。
    • 最近审查针对 df8de7376c21435679b4d1e6fc87e11726ef1e7a,复用了作者运行结果;没有独立 Go/cluster/BVT 执行及原始作者运行日志,当时五项 CI 尚未完成。最终 PR head 为 cc890a2341a99791a2034bd26a5f562d3969936d,不能据此前审查声称最终头全绿。历史 BVT/4.2.8 证据不当作本轮运行。
    • 本轮只核验远端证据和修复范围,未运行本地测试。返回补丁行数与元数据相符,但缺少文件头,未独立完整枚举 66 个文件。

    请 @Ariznawlll 在新合并版本复测受支持的停止 4.2→main 升级:使用干净官方前驱,记录首次 SQL 可访问时 PARTITIONS 已为当前定义,覆盖系统/普通租户、缺失/过期定义、读取和协调失败不放行、重启与幂等协调。同时保留原普通表唯一 NULL 行、分区表统计来源、租户权限和内部对象排除回归。真实 release 多 CN/生产规模成本仍待验证;不将混合版本运行、降级或 unreleased-main catalog 升级纳入已支持合同,也不要求 backport。

    保持 issue open,交 QA 验证;转测不等于验收通过。

  8. slyunnn commented on Nov 12, 2026

    @slyunnn

    Regression and extended verification for #31927 (2026-11-12)

    Verification Environment

    • Target: main@4760bcaa88b23fabe064b1631b624c0e8c40d549, Fix native preparation and stabilize CI tests (Fix native preparation and stabilize CI tests #32574), frozen from the remote branch at test start. A fresh release build and git_version() at all endpoints confirmed runtime identity.
    • Topology: 2 CN / 1 TN / 1 Log service / Proxy, cohosted locally on macOS arm64. Proxy 127.0.0.1:6001, CN1 127.0.0.1:16001, and CN2 127.0.0.1:16002 were connected and actually exercised, rather than health-checked only.
    • Clients: PyMySQL text protocol and the existing Java mo-tester with JDBC metadata comparison enabled. No MatrixOne service source was modified.
    • Upgrade source: unmodified official v4.2.5 Linux arm64 release binary, commit 1a44f3d; release ZIP SHA-256 5cee90a0904f32fc52b06c09891129501e3b293a3d86d73cbff398a2b3325736 matched the published digest. Its isolated two-CN topology was fully stopped and backed up before the new binary opened its data. Raft hostname was explicitly preserved across the container-to-host transition.

    What Was Covered

    • OK — Original ordinary-table example: exactly one row with NULL partition fields, including empty and indexed ordinary-table controls.
    • OK — Range-partition row count and metadata; ordinary statistics matched mo_table_rows / mo_table_size for the parent, and partition statistics matched their physical partition identities.
    • OK — Internal indexes, partition backing tables, views, sequences, and temporary objects excluded by the existing BVT. A legitimate name containing an internal-looking substring remained visible.
    • OK — System and ordinary tenants, cross-tenant isolation, and a restricted user's table-level visibility on all three endpoints.
    • OK — Real stopped official-release upgrade with pre-existing data and indexes in system and ordinary tenants. The old binary returned 0 rows for the ordinary table in both tenants before upgrade. CDC-task and snapshot preflight inventories were empty.
    • OK — Six independent first-connection observers: system/ordinary tenant through Proxy/CN1/CN2. Each first accepted SQL session already returned the correct unique NULL-partition row, correct runtime identity, and preserved data. First connection times were approximately 20.3–20.9 seconds after launch; no accepted-session stale-view window was observed. Repeated immediate reads remained correct.
    • OK — Restart of the already-upgraded same directory, again observing first accepted sessions for all six combinations: definitions and data remained correct.
    • OK — Existing startup tests: current/stale PARTITIONS, read/replace errors preventing ingress, exact current-system-definition checks, and initialization retry/cancellation.
    • Not covered — Production Linux-to-Linux deployment, large tenant/catalog populations, mixed-version operation, downgrade, and upgrades from unreleased-main catalogs. Admission error injection was tested at the component seam, not by corrupting a real catalog.

    Findings

    PR #32197, fix(sql): honor DESC column filters and ordinary table partitions, merge 547d2cb2de0c1e16767290e3575a468f89dabe5c, fixes ordinary-table rows and statistics while preserving visibility. PR #32307, fix: consolidate stopped-upgrade cleanup and stabilize CI, merge 606ae4fb2a94890709a2d573aaee936a27442dc3, includes PARTITIONS in startup/admission coordination and removes the periodic repair owner. This run directly retested the earlier upgrade visibility gap.

    Predecessor shutdown limitation: service shutdown completion was logged after clients were drained, but the container reached its 60-second grace limit with only cgroup configuration watchers reported pending, then exited 137. The complete stopped data was backed up before upgrade. This is evidence for the tested stopped/recovery transition, not a claim that the predecessor's cgroup shutdown behavior is fixed.

    Large-data regression required: No for the reported row-shape and admission-ordering contract. Two populated tenants and actual stopped upgrade cross the necessary boundary. Production-scale catalog migration cost was not measured or claimed.

    MOTR / BVT Coverage

    Existing bvt_partitions_ordinary_31927.sql: 23/23 per endpoint, 69/69 total, with metadata comparison. Focused bootstrap/CN tests passed, including explicit read and replace failure cases. Shared catalog setup and process transitions ran serially; the six ingress observers ran concurrently with independent connections.

    Existing regression cases and focused developer tests were reused. No redundant MOTR case, test commit, or empty summary PR was created. Test setup, logs, and machine-readable observations remain in the isolated QA artifact directory.

    Final Conclusion

    Fixed on the tested main commit for ordinary-table PARTITIONS visibility and coordination before accepted SQL ingress, including the stopped official-release transition and restart described above. No separate 4.2-dev backport acceptance is implied.

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

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions