Skip to content

Table mo_catalog.mo_branch_metadata does not exist after upgrade #25077

Closed

Description

Summary

After upgrading the MatrixOne binary (e.g. rolling image update via Operator / MO Cloud gitops) without completing the metadata upgrade step, queries or features that depend on mo_catalog.mo_branch_metadata fail with table does not exist.

This is observed when auto-upgrade = false (MO Cloud default) and UPGRADE ACCOUNT ALL has not been executed after the image rollout.

Environment

  • Deployment: MO Cloud / Kubernetes + MatrixOne Operator (distributed cluster)
  • CN config: auto-upgrade = false (explicit in gitops / COS managed CN config)
  • Upgrade path: Binary/image upgraded (spec.version / mo-image-tag changed), schema upgrade step skipped or incomplete
  • Affected version span: At least MO 4.0.0+, where mo_branch_metadata is introduced via the bootstrap upgrade framework (v4_0_0/cluster_upgrade_list.go)

Steps to Reproduce

  1. Deploy MatrixOne at a version before mo_branch_metadata was introduced (or any version where the table is absent).
  2. Set CN config:
    [cn]
    auto-upgrade = false
  3. Upgrade MO binary only (e.g. update spec.version / mo-image-tag and roll CN pods) without running:
    UPGRADE ACCOUNT ALL;
  4. Connect as a tenant and use a feature that touches branch metadata (e.g. DATA BRANCH, snapshot/branch quota checks, or internal SQL referencing mo_catalog.mo_branch_metadata).

Expected Behavior

After a version upgrade, cluster-level catalog tables required by the new binary — including mo_catalog.mo_branch_metadata — should exist, and branch/snapshot-related features should work.

Either:

  • UPGRADE ACCOUNT ALL is run as part of the controlled release (MO Cloud default release flow), or
  • auto-upgrade = true triggers BootstrapUpgrade() on CN startup to apply cluster + tenant metadata migrations automatically.

Actual Behavior

mo_catalog.mo_branch_metadata is missing. Operations fail, for example:

table mo_catalog.mo_branch_metadata does not exist

(or equivalent doesn't exist / internal error when the engine expects the table).

Other v4.0.0 cluster-level objects may also be missing if the upgrade framework never ran, e.g. mo_feature_registry, mo_feature_limit, mo_ccpr_*, etc.

Root Cause (Analysis)

MatrixOne separates binary upgrade from metadata/schema upgrade:

Layer Mechanism What it does
Binary spec.version, Operator rolling update Replaces MO image (Log / TN / CN)
Metadata UPGRADE ACCOUNT ALL or auto-upgrade=true Runs bootstrap upgrade framework: cluster tables + per-tenant catalog migrations

With MO Cloud defaults:

  • auto-upgrade = false → CN does not call BootstrapUpgrade() on startup.
  • mo_branch_metadata is created in cluster-level upgrade entry upg_create_mo_branch_metadata (v4.0.0 cluster_upgrade_list.go).
  • Without UPGRADE ACCOUNT ALL, mo_catalog.mo_version / mo_catalog.mo_upgrade stay at the old state and mo_branch_metadata is never created.
  • Lazy per-tenant upgrade on login (MaybeUpgradeTenant) is not wired into the connection path, so connecting alone does not repair missing cluster tables.

Workaround

Run as sys tenant after image upgrade completes:

UPGRADE ACCOUNT ALL;

Verify:

-- cluster version
SELECT * FROM mo_catalog.mo_version ORDER BY create_at DESC;

-- upgrade progress
SELECT id, from_version, to_version, final_version, state,
       total_tenant, ready_tenant
FROM mo_catalog.mo_upgrade
ORDER BY id DESC;

-- table exists
SHOW TABLES FROM mo_catalog LIKE 'mo_branch_metadata';

Suggested Improvements

  1. Fail fast: If CN binary version ≥ 4.0.0 and mo_branch_metadata is missing, return a clear error at startup or first use: "cluster metadata not upgraded; run UPGRADE ACCOUNT ALL".
  2. Observability: Expose upgrade/schema drift in SHOW ACCOUNT UPGRADE or metrics (cluster version vs binary version).
  3. Documentation: Call out in upgrade docs that auto-upgrade=false + image-only rollout requires UPGRADE ACCOUNT ALL before branch/snapshot features are usable.
  4. (Optional) Consider creating critical cluster-level tables during bootstrap when binary is new but mo_version is old, even with auto-upgrade=false, or enforce upgrade completion before marking CN Ready.

Related Configuration

  • [cn] auto-upgrade — default false on MO Cloud
  • [cn] upgrade-tenant-batch — only relevant when auto-upgrade=true
  • COS spec.upgradeStrategy.upgradeSchema: true — triggers schema phase after component rollout
  • Manual: UPGRADE ACCOUNT ALL / UPGRADE ACCOUNT <name> [RETRY n]

Activity

  1. ghost
    self-assigned this
    on Jun 22, 2026
  2. ghost added theissue type on Jun 22, 2026
  3. ghost changed the title [-]Table mo_catalog.mo_branch_metadatadoes not exist after upgrade[/-] [+]Table mo_catalog.mo_branch_metadata does not exist after upgrade[/+] on Jun 22, 2026
  4. Repository owner unassigned on Jun 24, 2026
  5. Ariznawlll commented on Jun 30, 2026

    @Ariznawlll
    Collaborator

    验证了一轮升级路径,结论如下。

    测试 run: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/28425398530
    测试 workflow: MO Kernel Upgrade Test On TKE
    测试分支/提交:matrixorigin/mo-nightly-regression@fix/kernel-upgrade-path-workflow-main / 86c1c610fdaa58dbff80121423614146e3f82026
    测试结果:整体 success

    本轮覆盖的是 3.0.2 -> 3.0.3 升级路径,重点验证升级后 mo_catalog.mo_branch_metadata 是否存在、可读,以及真实 DATA BRANCH/SNAPSHOT SQL 是否能写入对应 metadata。

    1. 构建 base 镜像

    Job: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/28425398530/job/84227283285

    证据:base commit checkout + image push 成功。

    ref: b0544ba46ba599c94e1114877423d47f7060eb30
    HEAD is now at b0544ba ...
    VERSION=upgrade-path-28425398530-base-${LAST_COMMIT_ID}
    #20 naming to ***/matrixone-dev/matrixone:upgrade-path-28425398530-base-b0544ba done
    upgrade-path-28425398530-base-b0544ba: digest: sha256:f1953064ef0e8fc144b4620d06d2e1121435ef5c337fff8242419b5bc514b377 size: 1581
    

    2. 构建 target 镜像

    Job: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/28425398530/job/84227283337

    证据:target commit checkout + image push 成功。

    ref: bda2d138a48883cac6142c55f11a9dae4146f803
    HEAD is now at bda2d13 test: expand protected database BVT coverage (#25081)
    VERSION=upgrade-path-28425398530-target-${LAST_COMMIT_ID}
    #20 naming to ***/matrixone-dev/matrixone:upgrade-path-28425398530-target-bda2d13 done
    upgrade-path-28425398530-target-bda2d13: digest: sha256:d35fb4900d35336cf3a011244433dddc1047adbbc46bfc1fef6cad3dfb23c160 size: 1581
    

    3. 创建 base 集群

    Job: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/28425398530/job/84229614669

    证据:namespace/secret 创建成功,base 集群 9 个组件最终 Running。

    namespace/mo-upgrade-path-28425398530 created
    secret/tke-regression created
    secret/tke-registry created
    matrixonecluster.core.matrixorigin.io/nightly-regression-dis created
    nightly-regression-dis-dn-0          1/1 Running ...
    nightly-regression-dis-log-0         1/1 Running ...
    nightly-regression-dis-log-2         1/1 Running ...
    nightly-regression-dis-log-3         1/1 Running ...
    nightly-regression-dis-proxy-9n7n8   1/1 Running ...
    nightly-regression-dis-proxy-qfcq2   1/1 Running ...
    nightly-regression-dis-tp-cn-9c2z9   1/1 Running ...
    nightly-regression-dis-tp-cn-b44qv   1/1 Running ...
    nightly-regression-dis-tp-cn-sjk76   1/1 Running ...
    

    4. 升级前准备数据和租户

    Job: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/28425398530/job/84234551525

    证据:base 版本为 b0544ba,创建系统库测试表和 3 个租户,每个租户都有升级前数据。

    git_version()
    b0544ba
    create table upgrade_path_test.before_upgrade(...); insert into upgrade_path_test.before_upgrade values (1, 'base'), (2, 'tenant');
    create account ut_ac1 admin_name 'admin' identified by '${TENANT_PASSWORD}';
    create account ut_ac2 admin_name 'admin' identified by '${TENANT_PASSWORD}';
    create account ut_ac3 admin_name 'admin' identified by '${TENANT_PASSWORD}';
    account_name admin_name status
    sys          root       open
    ut_ac1       admin      open
    ut_ac2       admin      open
    ut_ac3       admin      open
    Tables_in_mo_catalog
    mo_branch_metadata
    

    5. 执行集群镜像升级

    Job: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/28425398530/job/84234626556

    升级参数:

    BASE_TAG: upgrade-path-28425398530-base-b0544ba
    TARGET_TAG: upgrade-path-28425398530-target-bda2d13
    AUTO_UPGRADE: false
    UPGRADE_TENANT_BATCH: 16
    

    证据 1:第一阶段 cn-first,DN 保持 base,Log/CN/Proxy 升到 target。

    dn: ready=1/1, image_tag=1/1 expected=upgrade-path-28425398530-base-b0544ba
    log: ready=3/3, image_tag=3/3 expected=upgrade-path-28425398530-target-bda2d13
    cn: ready=3/3, image_tag=3/3 expected=upgrade-path-28425398530-target-bda2d13
    proxy: ready=2/2, image_tag=2/2 expected=upgrade-path-28425398530-target-bda2d13
    

    证据 2:第二阶段 DN 也升级到 target,最终所有组件均为 target 镜像。

    dn: ready=1/1, image_tag=1/1 expected=upgrade-path-28425398530-target-bda2d13
    log: ready=3/3, image_tag=3/3 expected=upgrade-path-28425398530-target-bda2d13
    cn: ready=3/3, image_tag=3/3 expected=upgrade-path-28425398530-target-bda2d13
    proxy: ready=2/2, image_tag=2/2 expected=upgrade-path-28425398530-target-bda2d13
    

    6. 执行 schema/tenant metadata upgrade

    Job: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/28425398530/job/84237702345

    证据:AUTO_UPGRADE=false 场景下手动执行 upgrade account all; 成功。

    mysql -h "${MO_HOST}" -P "${MO_PORT}" -u"${SYS_USER}" -p"${SYS_PASSWORD}" -e "upgrade account all;"
    

    7. 校验升级结果、元数据表和数据

    Job: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/28425398530/job/84237775758

    证据 1:当前运行版本已经是 target commit。

    version()
    8.0.30-MatrixOne-v1.3.0
    git_version()
    bda2d13
    build_version()
    2026-06-30 06:46:36
    

    证据 2:升级前写入的数据仍可读。

    sys_rows
    2
    tenant_rows
    1
    tenant_rows
    1
    tenant_rows
    1
    

    证据 3:metadata upgrade 状态完成。

    mo_version:
    version version_offset state create_at           update_at
    3.0.3   1              2     2026-06-30 07:45:45 2026-06-30 07:45:56
    3.0.2   3              2     2026-06-30 07:26:00 2026-06-30 07:26:00
    
    mo_upgrade:
    id    from_version to_version final_version state upgrade_cluster upgrade_tenant total_tenant ready_tenant
    10001 3.0.2        3.0.3     3.0.3        2     0               1              4            4
    
    mo_upgrade_tenant:
    id    upgrade_id target_version from_account_id to_account_id ready
    10001 10001      3.0.3         0               3             1
    

    证据 4:本 issue 关注的 mo_branch_metadata 存在、可读,并通过真实 DATA BRANCH/SNAPSHOT 冒烟验证。

    detected target metadata version=3.0.3, target_ref=bda2d138a48883cac6142c55f11a9dae4146f803
    required_metadata_tables=mo_branch_metadata
    metadata table mo_branch_metadata: exists=1
    metadata table mo_branch_metadata columns:
    table_id    BIGINT UNSIGNED(64) ...
    clone_ts    BIGINT(64) ...
    p_table_id  BIGINT UNSIGNED(64) ...
    creator     BIGINT UNSIGNED(64) ...
    level       VARCHAR(65535) ...
    table_deleted BOOL(0) ...
    metadata table mo_branch_metadata readable:
    row_count
    0
    run DATA BRANCH/SNAPSHOT smoke with tenant ut_ac1
    branch_tbl_rows
    2
    mo_branch_metadata rows for branch_tbl=1
    metadata upgrade completed
    

    结论

    本轮 3.0.2 -> 3.0.3 升级路径验证通过:

    • base/target 镜像均构建并推送成功。
    • base 集群成功启动并写入升级前数据。
    • cn-first 升级过程中,Log/CN/Proxy 先到 target,随后 DN 到 target。
    • 最终 DN/Log/CN/Proxy 全部为 target 镜像。
    • AUTO_UPGRADE=false 场景下手动 upgrade account all; 成功。
    • mo_version / mo_upgrade / mo_upgrade_tenant 状态均完成。
    • mo_catalog.mo_branch_metadata 已验证存在、可读,并通过真实 DATA BRANCH/SNAPSHOT SQL 冒烟验证。

    注意:本轮 target metadata version 是 3.0.3,因此主要验证 mo_branch_metadata。mo_feature_registry / mo_feature_limit 属于 4.0+ 目标版本路径,需要另起 4.0 target 的升级 run 覆盖。

  6. Ariznawlll commented on Jul 6, 2026

    @Ariznawlll
    Collaborator

    测试通过

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

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions