Skip to content

[Bug]: mo-dump hangs when independent views contain each other's names in string literals #30555

Closed
matrixorigin/mo_dump
#53

Description

@Ariznawlll

Consolidated tracking scope: mo-dump view dependency false positives and bounded ordering

Original reproductions and discussions remain available in the source issues below. Administrative consolidation is not a claim that a defect is fixed. Each input family and execution path retains independent acceptance.

Included reports

  • #30672 — [Bug]: mo-dump hangs forever (100% CPU in adjustViewOrder) when view DDL text false-matches another view's name — substring dependency graph builds fake cycles with no guard; truncated dump still replays DROP DATABASE

Acceptance checklist

  • Retain string-literal, projection/derived-column alias and comment collisions as independent false-dependency regressions; they must not create graph edges or an infinite loop.
  • Verify real one-way/cross-schema dependencies retain correct order and genuine cycles or unresolvable dependencies return a bounded diagnostic.
  • Keep partial-output handling explicit: a failed or interrupted export is not a valid backup, even if it already emitted DROP DATABASE.
  • Reuse merged fix: prevent false view dependencies and cyclic dump hangs mo_dump#53 (fix: prevent false view dependencies and cyclic dump hangs mo_dump#53) and revalidate the linked report against the fixed tool. Its merge is not fresh runtime evidence for this consolidation.

从 matrixorigin/mo_dump#48 迁入主库跟踪。以下保留原问题的复现、验证和白盒证据;修复范围是独立的 mo_dump 工具,与 MatrixOne 主库联动验收。

Description

两个互不依赖的合法 VIEW,只要各自的 SQL 字符串字面量包含另一个 VIEW 名称,mo-dump 的视图排序会把它们误判成循环依赖并进入无进展的无限循环。导出不返回、不写 MODUMP SUCCESS,输出文件仅有数据库头部;整库逻辑备份因此无法完成。

Environment

  • MatrixOne main: 75ff736835c3d00d40dc00a0a1d3b11129388e5b,本地隔离 LOG/TN/CN,frontend 127.0.0.1:26011。
  • mo_dump main: 324c33dbdc7075cd5d7beaafd1e15c76709dd442,macOS arm64,Go 1.26.5 make build。
  • 日期:2026-10-19。

Steps to reproduce

CREATE DATABASE d;
CREATE VIEW d.va AS SELECT 'vb' AS marker;
CREATE VIEW d.vb AS SELECT 'va' AS marker;
SELECT * FROM d.va; -- vb
SELECT * FROM d.vb; -- va
gtimeout -k 1s 3s ./mo-dump -u root -h 127.0.0.1 -P 26011 -db d > d.sql

实际两条 VIEW 都是常量查询,没有表/VIEW 引用,也没有依赖环。

Actual behavior

mo-dump 3 秒内始终不返回,被 gtimeout 终止,退出码 124。在三个完全独立新库中重复为 3/3。每份输出文件只有 188 字节的 SET foreign_key_checks 和 DROP/CREATE/USE DATABASE 头部,没有 CREATE VIEW 或成功标记。进程终止后 MO SQL 连接仍可正常查询这两条 VIEW;没有遗留 mo-dump 进程。

Expected behavior

没有真实依赖的视图应当有限时间内导出并可恢复;即使存在真实循环或无法确定依赖,也应返回明确错误而不是无限循环。

Stability and controls

  • 复现:独立数据库 exp_modump_view_a/b/c 各 1/1,合计 3/3,均超时退出 124。
  • 正常对照:dep1 AS SELECT 1 AS x、dep2 AS SELECT x+1 AS y FROM dep1 有真实单向依赖;导出 9 ms 返回 0,输出正确的 dep1→dep2 顺序及 MODUMP SUCCESS,重新导入后 SELECT * FROM dep2 返回 2。
  • 失败原子性:导出操作没有修改源库;三个源库的 VIEW 可继续查询;不完整输出文件不能用于恢复,调用方需要检查进程退出状态。

Code analysis

cmd/mo-dump/main.go 的 adjustViewOrder 用 strings.Count(createTable[i], tables[j].Name) > 0 推断视图依赖,不区分对象引用和字符串字面量,因此上述两个定义被各计入一条伪依赖。随后 for order < len(viewName) 只在 viewCount[i]==0 时推进 order,但没有“本轮没有进展”的退出条件;两个计数都非零时永久循环。这是代码和 3/3 黑盒结果一致的根因。

Evidence

Regression coverage

建议加入真实 VIEW 依赖、无依赖但字符串包含对方名称、注释/列别名包含对方名称、跨 schema 引用、无法解析依赖和非法循环边界。排序循环需要明确无进展检测;集成测试应设置进程超时并验证导出文件可导入。

主库关联

原始问题:matrixorigin/mo_dump#48。相关代码位于独立仓库;此处作为主库统一追踪入口,修复后需要跨仓库验证导出、恢复及数据一致性。

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. added
    severity/s0
    and removed on Oct 19, 2026
  5. assigned and unassigned on Oct 23, 2026
  6. slyunnn commented on Oct 26, 2026

    @slyunnn

    Regression and extended verification for #30555 (2026-10-26)

    Verification Environment

    • MatrixOne main: 4769417cdce5531c9771644eca49f1e71d8f654c — fix(plan): preserve replayable defaults and dump fingerprints (#31067). The running binary was rebuilt from this commit, restarted, and checked with git_version() at all endpoints.
    • Topology: 2 CN / 1 TN / 1 Log service / Proxy. MySQL text-protocol connections succeeded through Proxy 6001, CN1 16001, and CN2 16002; the original dump and restore were executed separately through each endpoint.
    • mo-dump latest main: 82760a085cf4a9dedfab66008cfc6b2f7cc1ebae, locally rebuilt. Associated fix: mo_dump PR #53, merge commit f33f68e554e2d8fb41c8746414e4b12bdc3c1e33. It replaces string-count-based ordering with parsed relation dependencies and bounded ordering/error handling.

    What Was Covered

    • OK — Original independent views: va contains string literal 'vb'; vb contains 'va'. mo-dump completed within 20 seconds without a false dependency cycle through Proxy, CN1, and CN2.
    • OK — Happy path: all 8 exported views were present, the dump reported MODUMP SUCCESS, and restore plus subsequent queries succeeded at all 3 endpoints. Restore sent each SQL statement separately; a whole-file multi-statement packet was not used.
    • OK — True one-way dependencies: same-database and cross-database dependent views were ordered before restore. Cross-database export intentionally supplied databases in reverse dependency order; restored queries returned the expected value at all 3 endpoints.
    • OK — Alias/name collisions: two independent views used each other's names as projection aliases and exported/restored successfully at all 3 endpoints.
    • OK — Unhappy and boundary paths in the mo-dump Go tests: genuine self/cross-database cycles produce a bounded error; dependency failures propagate without a false successful view section. Full go test -count=1 ./... passed on the tested tool commit.
    • Not covered — Live SQL comments containing another view's name: the created test views were exported successfully, but MatrixOne normalized comments out of their persisted view definitions. The parser's comment-collision behavior is covered by direct Go tests, not by this live catalog path.
    • Not covered — Live creation of a genuinely cyclic view graph and forced mid-export interruption. The former is rejected by database semantics; bounded-cycle and partial-output behavior were checked at the tool-test layer, not asserted as end-to-end fault injection here.

    Findings

    The original hang did not reproduce with the fixed mo-dump: string literals and aliases no longer create false view-dependency edges. Export, ordered replay, and query checks passed on all three SQL routes. The initial attempt to send the entire dump as one client packet was incompatible with this restore path; replaying individual statements succeeded and is the evidence reported above.

    Large-data regression required: No. This defect concerns view-definition dependency parsing and no-progress ordering, not row count, batch/block, spill, concurrency, or data volume. The minimal two-view collision and real dependency/cycle boundaries exercise the relevant behavior without unrelated scale cost.

    MOTR / BVT Coverage

    No duplicate SQL-only MOTR case was added: a MOTR .test cannot directly validate the mo-dump command's dependency graph, timeout, and partial-output behavior. The owning tool's full Go test suite passed, and the live export/restore scenarios above provided command-level evidence. No new MOTR commit or daily/weekly PR change was made for this issue.

    Final Conclusion

    Fixed for the original #30555 false-dependency hang on the tested MatrixOne and mo-dump revisions. The issue remains open for maintainer acceptance; this verification does not claim whole-file multi-statement restore, live cyclic-view creation, or forced-interruption coverage.

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

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions