Skip to content

[Bug]: mo-dump reports sys database missing when another tenant has the same name #30579

Closed as not planned
matrixorigin/mo_dump
#66

Description

@Ariznawlll

问题

系统租户与普通租户有同名数据库时,系统租户默认执行 mo-dump -db <name> 误报 database <name> not exists,尽管系统租户的表可正常查询。这使常见同名业务库在多租户实例上无法按文档默认方式导出。

版本与环境

  • MatrixOne main: 75ff736835c3d00d40dc00a0a1d3b11129388e5b
  • matrixorigin/mo_dump main: 324c33dbdc7075cd5d7beaafd1e15c76709dd442
  • 本地隔离 LOG/TN/CN,MySQL 协议;@@version=8.0.30-MatrixOne-v1.3.0 为运行时版本字符串,不代表源码 SHA。

复现

  1. 在系统租户创建数据库 dump_overlap_a 和表 t,写入 (1,'sys-row')。
  2. 在独立普通租户创建同名数据库、同名表,写入 (1,'tenant-row')。
  3. 系统租户连接查询 SELECT * FROM dump_overlap_a.t,正确返回系统租户的 (1,'sys-row')。
  4. 用系统租户凭据执行:
mo-dump -u root -h 127.0.0.1 -P <port> -db dump_overlap_a > dump.sql

实际退出码 1:modump error: invalid input: database dump_overlap_a not exists。换三个全新同名库对 a/b/c,SQL 与 -csv 两种导出各 3/3 相同。失败后两租户原表分别仍是 sys-row / tenant-row,没有被修改。

对照与预期

  • 同一系统租户命令加 -sys 后,三组均成功导出且只有 sys-row。普通租户直接导出三组均成功且只有 tenant-row。
  • 正常预期:默认整库导出按当前连接的租户识别数据库,系统租户不应因其他租户有同名数据库而误报不存在;也不得串入其他租户的数据。
  • -sys 在工具帮助中描述为“Dump system table from 'sys' account”,不是文档默认的普通整库导出参数,不能要求用户为所有系统租户业务库猜测加该开关。

白盒定位

cmd/mo-dump/main.go:getDatabaseType 查询 mo_catalog.mo_database 时,只有显式 -sys 才追加 account_id = 0;默认在系统租户下可取到多个同名目录行。随后 len(dbs) != 1 被统一翻译为“数据库不存在”。本次三个复现库的目录查询各返回系统租户和普通租户两行。getTables 也只在 -sys 时按 account_id 过滤,应一并检查,但本 issue 的已证实失败发生在 getDatabaseType。

回归建议

系统租户与普通租户同名库、同名表而内容不同;验证默认整库导出成功且仅包含当前租户数据,普通租户导出也只含其数据;覆盖 SQL 与 CSV 两种格式及重复运行。此轮未修改仓库或提交 PR。

Activity

  1. added this to the MO-202610 milestone on Oct 19, 2026
  2. added
    kind/bug
    on Oct 19, 2026
  3. added theissue type on Oct 19, 2026
  4. XuPeng-SH commented on Oct 22, 2026

    @XuPeng-SH
    Contributor

    This report is now tracked together with #30562. The canonical issue retains explicit acceptance cases for the behavior described here. This is an administrative duplicate/consolidation closure only; the underlying defect is not claimed fixed. The original description and discussion remain available on this issue.

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

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions