Skip to content

[Bug]: view-description restart reuses expired query context after lifecycle admission wait #30451

Closed

Description

@iamlinjunhong

Is there an existing issue for the same bug?

  • I searched open and recently closed issues for TestViewDescriptionTwoCN, view_description_two_cn, view-description/admission and context-deadline signatures.

No matching tracking issue was found. Existing restart/AutoID or deferred account-cleanup issues concern different tests and failure phases.

Branch Name

codex/loom/develop/9bcbdc05d7d8f3c6563484ed14a3128831d9ba553ac0c30fd2f05ce1ff68fa0a; official main control below.

Commit ID

PR #30312 exact head 445fe006be874697bc2d1dcf4944b1c428b477d8.
Clean current official main aa4b6eddfdad54d11be6fd75a5675eb9801f6690.

Other Environment Information

CI: Go 1.27.1 Linux/amd64, CGO, -short -tags matrixone_test, no race detector, -covermode=set, 504-package coverpkg, package parallelism8, Go test timeout20m.

Local control: Go 1.27.1 Darwin/arm64, verified native CGO libraries, same short/tags/race-off/covermode/parallelism/timeout, plus vet=all. Local coverpkg is the unfiltered509-package superset; CI excludes pkg/catalog and four logstore driver packages. This is a controlled same-mechanism main reproduction, not an exact Linux/full-CI reproduction.

Actual Behavior

The complete Coverage JSON has1,045,271 events and exactly one failed case, TestViewDescriptionTwoCN (265.18s), plus its package failure. The downstream Coverage job rejects its failed producer; no coverage-rate verdict is computed. CI Required also reports a separately failed ordinary race UT producer with independent failures, tracked separately.

cluster18004 initial admission wait9.999us; service-start4.189668s ready
02:17:34.106 initial Close releases admission (hold5.597587s)
restart admission wait4m18.493208367s
02:21:52.600 restart admission acquired
restart service-start893.646ms ready
view_description_test.go:174 -> line102 QueryRowContext:
  context deadline exceeded
--- FAIL: TestViewDescriptionTwoCN (265.18s)

The test creates one three-minute query context after the initial cluster startup, then reuses it after closing/restarting the cluster. Close releases the runner-wide exclusive lifecycle flock. Start reacquires it using a background admission context, so another package can hold the gate longer than the retained query budget. Service restart succeeds, but the first metadata query then receives an already expired context.

Expected Behavior

The restart/query acceptance contract should distinguish lifecycle admission waiting from the query execution budget and preserve all metadata/persistence oracles. Diagnose the budget/ownership boundary instead of weakening assertions, disabling admission or blindly extending a timeout.

Steps to Reproduce

Run the unchanged named test on official main with a private, short TMPDIR and native CGo inputs:

cover_pkgs=$(go list -mod=readonly ./... | paste -sd, -)
.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -vet=all -short -v \
  -tags=matrixone_test -p8 -timeout=20m -covermode=set \
  -coverprofile="$TMPDIR/view.cover" -coverpkg="$cover_pkgs" \
  -run '^TestViewDescriptionTwoCN$' ./pkg/tests/sqlintegration/multicn

The command above documents the local509-package superset. To match the CI instrumentation scope instead, filter the list with grep -v 'driver\|engine/aoe\|engine/memEngine\|pkg/catalog' before joining it.

For an ordered contention control, monitor stdout for the initial MO_UT_SETUP ... phase=service-start ... status=ready. Then, from a separate thread/process using the same TMPDIR, open mo-test-cluster-lifecycle.lock and block in fcntl.flock(fd, LOCK_EX). The initial cluster still owns it. On the first Close the waiting holder acquires it; retain that lease for185seconds, release it and join the holder. This models a competing embedded package's lifecycle lease without editing the test or pausing the tested process. Capture holder-acquisition/release timestamps, actual admission wait and the final assertion; a run where the holder misses the restart window is inconclusive. Use a finally/termination cleanup for the holder.

Additional information

Clean exact-main control, with all11,340 exported Git blobs verified against main and unchanged tracked native sources and provenance-verified native inputs:

Control Terminal result Observed evidence
no competing lease PASS same named test/coverage command, process23.898s
ordered competing lease185s FAIL, same174->102 deadline actual restart admission185.160314916s; service-start1.036193250s ready; process203.447s

The precise comparison uses a complete metadata-free Git archive, because the managed lane forbids switching another branch or creating a worktree. No main checkout or source patch was made. Verified native inputs were reused read-only through temporary links, removed on exit. The first experimental run hit Darwin's Unix-socket path-length limit; it is preserved as an environment error and not counted as a reproduction. Both controls above use a shorter private runtime directory.

The controlled failure is the same lifecycle/deadline mechanism on clean main: admission alone exceeds the180s budget before the next query. The extra five instrumented packages cannot account for the controlled185s external lease or change that budget relation. This does not identify the actual CI lock holder/root workload or establish platform/full-suite stability.

The full PR diff changes SQL conversion diagnostics/folding and associated tests; it does not change this view-description test, lifecycle admission, restart or context ownership. At this exact head, SCA, both enabled BVT lanes and all five owning Coverage packages (sql/colexec, sql/plan/rule, sql/plan/function, sql/plan, tests/dml) pass. No unrelated source, test timeout, assertion, retry or skip is changed.

After this and the independent ordinary-UT failures have tracking evidence, request one failed-jobs rerun of run38992970982. A repeated signature requires renewed attribution, not an automatic rerun loop.

Activity

  1. MatrixAdventurer commented on Oct 18, 2026

    @MatrixAdventurer
    Contributor

    由 LW 授权的 ChatGPT Personal 智能体提交。

    续接记录:基于固定源码 38a27e6,1 文件 +4/-0 候选补丁及隔离验证方案已获独立 review agent Approve(仅静态审核,尚不代表实际门禁通过)。已在本人 fork MatrixAdventurer/matrixone 创建 verify/30451-context-generation 分支,验证提交 981b23f,执行受控 admission 等待红绿测试、拥有包测试、race 与静态检查。该分支的额外验证脚本不属于产品修复 PR;未创建产品 PR,未修改上游分支。后续按实际 Actions 结果补充证据。

  2. MatrixAdventurer commented on Oct 18, 2026

    @MatrixAdventurer
    Contributor

    由 LW 授权的 ChatGPT Personal 智能体提交。

    首次验证39096764917:native generation/原测试无竞争对照通过;真实外部竞争红对照命中第二次admission等待185.016335274秒,随后SQL context deadline exceeded、named test失败。修复后named test虽通过,但外部holder未赢重启竞争(第二次等待8.483µs),driver正确判无效失败,不能当同故障green;完整原证据artifact12124674266保留。

    已改用确定性私有Unix socket握手:仅隔离controlled阶段在Close后等待ACK,外部driver实际LOCK_EX|NB取得同一flock才ACK,Start真实等待185秒。红绿相同插桩、180秒SQL预算及断言不变,保存插桩diff/原hash,finally字节恢复原源码;后续包/race/静态检查对无插桩准确拟提交文件执行。driver独立review Approve,SHA2567b880e8ec7138efee0e32a20e02ad128b774c80f9fab9aeb267d5995b5fe5042。Python编译通过,本地Unixsocket协议检查EPERM未执行。旧基线确定性run39097594508为历史记录,不代表最新main门禁。

    新鲜度:main已到3c07fac240311d6f2b706674614ed6034e97ff79。目标test Gitblob78068bbc7532b23018f6bef0863c2eb62ac861fe和mo-dev/mo-self-review技能未变,但共享fixture及所属multicn包已变;因此已独立复审最新embed/admission/新增包内测试及最新计划,明确Approve后新建本人fork verify/30451-latest-main,提交83ed8484f8ac69e90620860ea219059d5f476c58,实际run https://github.com/MatrixAdventurer/matrixone/actions/runs/39098117472 已启动。lint基线也更新为3c07,全部原control/red/green/拥有包/race/静态命令预算保留,按最新包实际结果统计,禁止沿用旧4测试数量。尚未全部完成,无产品PR。产品候选仍1文件+4;所有分支、commit、只读核验由署名主体执行。

  3. MatrixAdventurer commented on Oct 18, 2026

    @MatrixAdventurer
    Contributor

    由 LW 授权的 ChatGPT Personal 智能体提交。

    修复已提交:#30517,目标 main(已核验上游无 dev),用户 fork 分支 MatrixAdventurer:fix/30451-restart-query-context,固定 head 1c5bc4a36d0362b5a0ffe6c257ec9031fe81b028,最终 1 文件 +4/-0。

    验证记录:https://github.com/MatrixAdventurer/matrixone/actions/runs/39098117472 。实际 185 秒生命周期锁等待:原代码查询超时失败,修复后通过;所属包 5 个根测试、独立 race 运行、native generation、gofmt、molint/vet、增量 golangci-lint 均通过。独立 review agent 明确 Approve。具体命令、固定基线、临时注入及恢复方法和验证范围见 PR 正文。未声称完整仓库 CI 通过。

    操作记录:本智能体已在用户 fork 创建上述独立分支和 PR,给 Issue 添加 XuPeng-SH 并保留原负责人 matrix-meow;PR 指派及请求审阅均为 XuPeng-SH。已读回确认:Issue assignees [XuPeng-SH, matrix-meow],PR assignees/review requests [XuPeng-SH],正文与提交前内容一致,GitHub mergeable=true(behind)。未合并、部署或关闭 Issue。上游合并 CI 待实际完成。

  4. XuPeng-SH commented on Oct 19, 2026

    @XuPeng-SH
    Contributor

    本轮独立实测(2026-10-19,main 2ad1d7e,Linux/amd64、Go 1.27.1、本轮重新构建 native CGO)通过:

    .agents/skills/mo-dev/scripts/mo-cgo-test -p 1 -count=1 -v -timeout=10m -run '^TestViewDescriptionTwoCN$' ./pkg/tests/sqlintegration/multicn

    退出码 0,命名测试 6.68s。真实两 CN 完成 metadata/snapshot restore、Close/Start、prepared/CTAS 和数据持久性断言;测试在 restart 前显式取消旧查询 context,使用新查询预算,原 metadata/data 断言保留。本次没有额外制造185秒锁竞争,不将已有红绿控制当成本轮执行。main 修复 #30517 的报告范围验证通过,转 Ariznawlll;移除 XuPeng-SH 和 matrix-meow 的开发指派。本 issue 不以无关4.2回迁为转测条件。

    原始记录:pr-audit-continue21/logs/view-restart-normal.{log,command,exit}。

  5. Ariznawlll commented on Oct 19, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • 分支:官方 main
    • commit:fed3bf59700158212a9135d0b619c3849034bb65(执行前及测试后均核对官方 main)
    • 部署方式:本机隔离嵌入式 2 CN / 1 TN / 1 LogService、真实 MySQL TCP;同一测试集群 Stop/Start,保留 catalog 与 UUID。未使用共享环境。
    • 测试日期:2026-10-20(北京时间)
    • 修复关联:fix(tests): renew view query context after cluster restart #30517 已 MERGED,merge commit adbdd5c718baca6e4c054194f888b48a4f84a0a2 已进入上述 main。此次修复的是测试在重启后错误复用旧查询 context 的生命周期,不把它称作产品数据路径修复。

    原问题验证

    原失败机制是在 TestViewDescriptionTwoCN 的第一次 cluster 生命周期结束后,第二次 Start 等待测试 admission 锁约 185 秒,随后查询复用已耗尽的 180 秒 context。修复前的受控红对照及修复后绿对照见 #30517 的验证记录。

    本轮在最新 main 的隔离临时测试插桩中,只在原测试 cluster.Stop() 与 cluster.Start() 之间,通过同一个 mo-test-cluster-lifecycle.lock 安排 185 秒独占持锁;不改原 metadata、snapshot、prepared、CTAS、数据值与清理断言。真实 Start 的等待加启动耗时分别为 3m6.0848615s、3m6.167324s、3m5.825751667s,每次均超过旧 180 秒预算;三轮命名测试全部 PASS,重启后的新 context 查询没有 deadline exceeded。插桩随后已撤回,隔离源码工作树恢复干净。

    Happy Path 覆盖

    1. 两个 CN 各自读取源 View 与嵌套 View,information_schema / DESC / 实际查询的类型和值断言均通过。源列从 varchar(60) 修改为 varchar(90) 后,返回修改后的描述与 changed 值。
    2. 保存快照后恢复源表:源表物理 rel_id 更换、View 的 rel_id 不变,两个 CN 上 prepared metadata 与 CTAS 均回到 varchar(60) / saved;真实 Stop/Start 后同样通过。
    3. 无额外持锁的原样命名测试在同一 SHA 上以 -race -count=3 通过,3/3;受控 185 秒持锁场景 3/3 通过。

    Unhappy Path 覆盖

    1. 超过旧查询预算的 admission 等待已按上述实测 3/3 覆盖;没有静默跳过重启后的元数据/数据断言,也没有把旧 context 超时当作可接受结果。
    2. 原测试在重启前关闭两条旧连接、取消旧 context,重启后创建新查询预算并重新连接;每轮完成后快照和临时数据库清理,测试集群 Close,未出现连接残留或进程超时。
    3. SQL 无效输入、权限拒绝与故障网络注入不适用于此测试 context 生命周期问题,本轮未执行、亦不据此声称相关产品能力通过。

    白盒验证

    • TestViewDescriptionTwoCN 是真实嵌入式服务 + SQL 集成测试,不是仅测试一个 mock context。定向 -race -count=3,3/3 PASS;受控同锁 185 秒 admission 场景 -count=3,3/3 PASS。
    • 持锁使用测试专用临时插桩,不是仓库的产品改动;命名测试原有断言保留,跑完已撤销并检查 git status --short 为空。

    回归测试

    测试证据

    • 最新 main 受控持锁:mo-cgo-test -p 1 -count=3 -v -timeout=12m -run '^TestViewDescriptionTwoCN$' ./pkg/tests/sqlintegration/multicn,输出三轮 admission/Start 实测耗时如上,PASS,耗时 574.919s。
    • 撤销插桩后的原样 race:mo-cgo-test -race -p 1 -count=3 -timeout=10m -run '^TestViewDescriptionTwoCN$' ./pkg/tests/sqlintegration/multicn,ok,测试运行 43.526s。
    • 可复核的修复及红/绿控制记录:PR #30517;本轮隔离工作树测试后为干净状态。

    测试结论

    测试通过。

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