Skip to content

test: reduce CDC discovery waits and partition fixture footprint - #29836

Merged
XuPeng-SH merged 5 commits into
mainfrom
codex/ut-racing-systematic-20261011
Oct 11, 2026
Merged

XuPeng-SH merged 5 commits into
mainfrom
codex/ut-racing-systematic-20261011

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Related #29562; follow-up to #29807. This improves a measured part of UT racing. The full ten-minute CI and lower-memory goal is not established.

What this PR does / why we need it:

Use the existing CDC execution path

Four private CDC generation/ACK/EndTs/setup-diagnostic suites spend time waiting for task polling and table discovery. Reuse their existing fixture owner, configure task fetch before CN construction, and select a 1s periodic table scan during test reset. Default production and other test resets retain 15s scanning, 5s retry, and the existing fault-injection precedence. Close the captured private detector on scenario exit. First-use reset also consumes the existing singleton initialization so the next Get cannot replace the configured detector.

Remove the previously introduced manual scan/readiness helpers and synchronous/deferred joins. Those waits could block cleanup while a callback waited on the real paused CN, because its context belongs to the task/CN rather than the test helper. Tests now observe the existing periodic callback through their original bounded SQL/data/error waits; task/CN teardown remains the cancellation owner. No added shutdown coordinator, active-routine access, registry or state machine.

Preserve passive-before-active fixture reuse, real two-CN source locks, EndTs crossing and late-table rejection, generation replacement, target identity/epoch checks, rollback/replay, and transient/permanent diagnostics. All original scenario oracles remain. No CI/workflow, canonical public takeover cadence, GC or production lifecycle changes. One immutable private scan-period field is read when constructing the existing ticker; the optional reset override is test-only.

Reduce partition fixture footprint

All current partition SQL/metadata/index/affected-row scenarios use CN0. Reuse the same shared fixture with one CN rather than three, preserving LOG/TN, deadlines, all assertions and both full 100K-row S3 scenarios. Dedicated shard topology is unchanged. Historical 3/1/1/3-CN controls showed lower one-CN RSS but mixed timings, so no stable partition wall gain is claimed.

Final validation

Base 64b715a8234e272794185e2acc98ad58a8346c65; final content fingerprint b02dec280d06d4c6240f9b06e8ed9c402a51df9647161481eb678cb1315ea871. Four changed files: a narrow detector test seam, provider UT, private embed tests and partition fixture.

  • Complete embed normal with -short -tags=matrixone_test -count=1 -vet=all: PASS, 259.204s; 113 PASS and two unchanged skips. Complete embed short race: PASS, 316.616s; same roots/skips.
  • Complete CDC owning package normal/vet and race: all 480 roots PASS in each mode (9.559s / 10.964s).
  • Public default CDC lifecycle and takeover consumers: both roots PASS in normal/vet and race (100.750s / 103.194s).
  • Executed review-only normal and race probes: actual paused CN callback cancelled by fixture teardown without any Resume rescue; intentional child FailNow caught by the outer test; subsequent fixture initialized and executed SELECT 1. Both outer probe runs PASS. Temporary probe removed before final package validation.
  • Unchanged partition proof reused: all 30 roots PASS in full normal/vet (12.204s, both 100K-row S3 cases) and short race (23.666s); source, native inputs and relevant default behavior unchanged.
  • Incremental configured golangci-lint 2.14 over cdc/embed/partition and direct frontend/sqlintegration consumers relative to the verified base: zero issues. gofmt and diffcheck clean; vet checks passed. Repository molint exit0 reports eight recover advisories in unchanged files/function, verified byte-for-byte against the base; no new advisory or suppression.

Matched native measurement

Darwin/arm64, Go1.27.1, GOMAXPROCS=8, matching independently built CGo. Complete pkg/embed -short -race -count=1; test-binary /usr/bin/time -l excludes compilation. No contending tests/static checks. Same 115 roots, 113 passing and the same two existing skips.

Full pkg/embed Wall(s) CPU user+sys(s) Peak RSS(bytes) Peak footprint(bytes)
Current-base baseline 442.54 249.15 3332685824 8521886784
Final periodic path 316.61 206.85 3979542528 7824894392

Whole-package wall improves 125.93s / 28.46%; CPU improves 16.98%. Four affected CDC roots total 221.00 → 97.48s, accounting for 123.52s of the improvement. Peak RSS rises 19.41% / 617 MiB; the suggested 5% target was missed. Peak footprint falls 8.18%, a separate metric that does not cancel the RSS increase. This is an explicit accepted resource tradeoff; its cause and final Linux headroom are not established.

These native samples do not establish equivalent Linux CI savings or whole-job memory improvement. The previous manual-scan implementation measured 348.87s / CPU225.72s / RSS3627581440 on this base and is superseded by the cancellation-safe periodic path. Earlier-base manual trials also showed RSS 17–18% above their controls; a bounded teardown GC trial worsened RSS and was withdrawn. Those results remain historical evidence rather than being silently replaced.

Limits and review

The previous head aaa02d passed Linux racing, with actual workload 70m59.976s, embed 539.26s, max embedded anonymous memory 6.04GB and no OOM. Its ARM SCA and preflight also passed. That is previous-head validation, not proof of this update. No matched Linux baseline establishes a causal whole-job reduction. New-head CI is pending; no live CI action or workflow change was made.

Changing canonical fixture cadence globally failed a real takeover test and was withdrawn. The delivered interval override stays within the four private suites. The verified P2 cancellation finding is addressed by deleting the blocking path and validated with actual paused-CN cancellation and child FailNow/next-fixture probes; probes were removed before final package validation to avoid daily fixture cost.

Required actual gpt-6.1-sol / xhigh design and final overall review: PASS, no unresolved material blocker for PR publication, including cancellation, original oracles, existing ownership, test quality and the explicit resource tradeoff. Session 01a126c6-4ae9-77b1-955a-47697a1f06fc; exact final content fingerprint above reviewed. Final commit 2ae7dce80b01796c65717a99e2325e37220a4a79 has the same validated content. Final-head Linux CI remains unvalidated; the broader 600-second/lower-memory goal remains unproved.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH changed the title test(partition): use one CN for partition contract tests test: reduce CDC discovery waits and partition fixture footprint Oct 10, 2026
@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

Final overall review — actual gpt-6.1-sol / xhigh

PASS for local PR publication; no unresolved material blockers. Reviewed aaa02d071bcc81a71b06166824d757b0facaec24 against main 64b715a8234e272794185e2acc98ad58a8346c65. Actual model/effort confirmed by CLI session 01a126c6-4ae9-77b1-955a-47697a1f06fc.

  • Reuses existing private CDC fixture owners and the real detector scan. Async barrier scans release and join before cleanup, including assertion abort; readiness is context bounded and only an explicitly expected Failed state can complete an already-unregistered phase.
  • Retains real SQL/data/generation/identity/rollback/replay/EndTs/late-table oracles, actual two-CN lock coverage, and canonical public takeover behavior. Global cadence and GC experiments were withdrawn.
  • Current-base embed normal/vet and race: 113 PASS plus the same 2 existing skips out of 115 roots. Partition full normal/S3/vet and race: all 30 PASS. Incremental configured lint, molint, gofmt and diffcheck: PASS.
  • Matched full embed racing test binaries: 442.54s → 348.87s, 93.67s / 21.17% lower wall, 9.40% lower CPU. Peak RSS 3,332,685,824 → 3,627,581,440 bytes (+8.85%, ~281 MiB). Historical prior-base RSS increases and the rejected GC trial remain disclosed in the PR body; the suggested 5% RSS target was not met.

This is an explicit resource tradeoff. Linux final-head capacity and whole CI duration are pending; #29562's ten-minute/lower-RAM acceptance is not established. No production or workflow changes are included.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head aaa02d071bcc81a71b06166824d757b0facaec24 against main@64b715a8234e272794185e2acc98ad58a8346c65.

This is a focused test-runtime change. The CDC fixtures still register through taskservice/catalog and call the production detector scan, matching and callback; the barrier-based cases join the callback before restoring hooks or cleanup. The two-CN source-generation contract remains multi-CN. The partition helper is only used by SQL/catalog partition tests, and the shard/distributed contracts remain in their separate package, so reducing its shared cluster from three CNs to one does not remove the coverage owned here. The one-second task fetch interval is test-only and leaves heartbeat/capacity settings intact.

Exact-head CI Required, Ubuntu UT, SCA, coverage, and pessimistic/PROXY multi-CN BVT are green. I found no confirmed correctness, lifecycle, or product-performance blocker in this delta. This review is COMMENT only because the PR is self-authored.

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

Deep review of aaa02d07 — REQUEST_CHANGES

One verified P2 supersedes the previous no-blocker recommendation.

The new scan helpers can prevent failure cleanup from reaching the cancellation owner. At the synchronous scan and the async join, the supplied context bounds registration only. The real callback uses its task/CN lifecycle context. release() releases the test barrier; it cannot cancel a callback waiting in TxnClient.New for CN recovery. A deferred join runs before DROP CDC and fixture shutdown, so after a scenario timeout/FailNow it can block the cleanup that would actually cancel that callback. The synchronous helper can likewise block before scenario cleanup is reached.

Executed an independent, bounded fault probe against the real embedded task and detector: inject actual TxnClient.Pause immediately before the unchanged production GetTxnOp/New; cancel the helper context; the join remains blocked; independent CN Resume releases it. The probe completed with its expected observations (10.51s), and its temporary test file was removed. Source confirms the paused wait has only callback cancellation, client close, or Resume release edges—not the helper's test context.

Please close this at the existing task/fixture cancellation owner: cancellation/failure must reach the actual callback before waiting for completion. Keep hooks/resources until the callback exits; simply timing out the join and leaving a scan goroutine running is insufficient. Add one discriminating cancelled-context/FailNow cleanup case with a blocked callback.

Other reviewed changes are coherent: existing fixture owners and real scan/callback path reused, no parallel state machine, explicit terminal-Failed race handling retains original diagnostics/data/identity/epoch assertions, actual two-CN ACK coverage retained, partition uses CN0 with all30roots/full S3 oracles preserved. No external inline comments or submitted reviews remain to reconcile; the earlier registration-race finding and rejected global cadence/GC experiments were handled.

Fresh exact-head Linux race and ARM SCA CI passed. The actual race workload was 70m59.976s, embed 539.26s; sampled embedded anonymous-memory max 6.04GB, no OOM, but cgroup reclaim pressure exists. This establishes execution, not causal whole-CI savings or lower memory. Native matched evidence remains 93.67s lower wall /9.4% lower CPU /8.85% higher RSS. The full ten-minute/lower-memory goal remains open.

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

P2 cancellation finding resolved; final review PASS

Fix in 2ae7dce80b01796c65717a99e2325e37220a4a79. This supersedes my P2 finding, which had correctly superseded the earlier PASS.

The fix removes all newly introduced manual scan/readiness helpers and synchronous/deferred joins. A callback waiting on the real paused CN can no longer block the test control flow from reaching its owner’s cleanup. Four private suites use the existing periodic scan at 1s, preserving default 15s scanning, 5s retry and injection precedence elsewhere. First reset cannot be overwritten by lazy singleton initialization; captured private detectors are closed on exit. All original data, errors, generation/identity/epoch, two-CN source-lock, EndTs/late-table and rollback/replay oracles remain. No new shutdown machinery or CI/workflow edits.

Validation:

  • Real paused-CN and intentional child-FailNow probes passed in normal and race modes, including subsequent fixture initialization and SELECT 1. No Resume rescue was used. Expected child exit 1 was explicitly checked by the passing outer probe. Temporary probes were removed before final package validation.
  • Complete embed: normal/vet 259.204s; race 316.616s; both 113 PASS and the same two existing skips.
  • Complete CDC: all 480 roots PASS in normal/vet and race. Default public lifecycle/takeover consumers: both roots PASS in both modes.
  • Unchanged partition full 30-root normal/S3 and race proof reused with relevant dependencies reconciled. Incremental configured lint over owning/direct-consumer closure: zero issues; formatting/vet/diffcheck passed. Molint exit 0 has eight advisories in byte-identical, unchanged code; no new advisory or suppression.

Matched native timed full embed race: 442.54→316.61s (-28.46%), CPU 249.15→206.85s (-16.98%), peak RSS 3,332,685,824→3,979,542,528 bytes (+19.41% / 617 MiB). The four CDC roots account for 123.52s of the 125.93s package saving. The RSS increase is an explicitly accepted publication tradeoff, not a lower-memory result. Footprint is a different metric; no cause of the RSS increase or final Linux headroom is established.

Actual gpt-6.1-sol with xhigh reasoning completed design, source/resource assessment and final overall review: PASS, no unresolved material publication blocker. Reviewed final four-file content SHA256 b02dec280d06d4c6240f9b06e8ed9c402a51df9647161481eb678cb1315ea871, session 01a126c6-4ae9-77b1-955a-47697a1f06fc.

New-head CI has not been validated. The earlier exact-head Linux PASS is historical evidence for this update. There is no matched Linux whole-job baseline or proof of the 600-second/lower-RAM goal; #29562 remains a Related reference, not a goal-completion claim.

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

Deep review — 2ae7dce80b01796c65717a99e2325e37220a4a79

结论:本轮未发现新增、可证实的阻塞问题;当前设计合理。上轮 P2 已关闭。全量 UT racing 的时间/内存优化目标仍未完成。

审查范围:base 64b715a → head 2ae7dce,完整四文件 diff,指纹 b02dec280d06d4c6240f9b06e8ed9c402a51df9647161481eb678cb1315ea871。逐项检查实现、测试、既有职责和评论;本轮未使用 subagent,未修改代码或 CI。

设计、职责与清理

  • TableDetector 继续负责周期发现,只增加构造/测试 reset 时确定的周期字段。生产及未指定周期的调用保持 15s、retry 5s,故障注入优先级不变。首次 reset 消费已有 once,防止首次 Get 覆盖私有实例;现有串行测试生命周期约束明确。
  • 私有 CDC fixture 复用已有 SharedTestCluster,不增加任务注册表、执行路径或清理状态机。此前在这四个场景中新增的手动扫描/readiness/同步与 defer join 已删除。
  • TableDetector.Close() 本身只取消扫描,不能当作 callback 已退出的证明。实际 callback 的取消、generation fence 和 drain 仍由 CDC executor/CN teardown 负责;夹具在 Run 退出后关闭,保留失败隔离。检查了 barrier release、hook 恢复及 OpenDbConn 恢复顺序,没有发现本次变更新增的等待环。
  • partition fixture 的当前场景均使用 CN0,改为 1 CN 符合这些 SQL/metadata 测试的职责;显式 options 仍可覆盖默认值。数据量、断言和两项完整 100K-row S3 场景保留,专门的 shard 3-CN 测试与 CDC 2-CN guard 保留。原三 CN 可能附带的分布式执行覆盖不能算作完全等价保留。

测试质量与 unhappy path

增量分别为:生产文件 +18/-4;测试 +96/-13;仓库文档 0。两项新增 provider UT 分别验证首次 reset/默认值恢复、真实 ticker 触发 callback,不增加 SQL 集群。四个 CDC 场景的原始数据、EndTs/late-table、generation/epoch、跨 CN source-lock、rollback/replay、瞬态/永久错误断言保留。

复用与当前指纹一致的执行证据:CDC 480 roots normal/race 均通过;embed 两种模式均 113 PASS、两个原有 skip;public lifecycle/takeover 两个默认周期消费者 normal/race 通过;partition 30 roots 的 full normal/S3 和 short race 证据有效。实际 paused-CN、无需 Resume 的取消,以及 child FailNow 后下一 fixture 执行 SELECT 1 的 normal/race probe 已执行通过。临时 probe 在最终整包验证前移除。本轮没有发现需要重复跑整包的新反例。

评论处理状态

  • P2:手动扫描等待阻断取消与清理:已解决,依据是删除引入的阻塞路径及上述真实取消/失败退出证据。
  • 此前 aaa02d 的 PASS 和旧 head 的 COMMENTED review:历史结论,由 P2 及后续修复复审取代。
  • 2ae7dce 的修复说明:代码和验证与说明一致;其中当时的“CI pending”由下方最新结果更新。
  • 当前无 inline review comments;Qodo 暂停通知不含代码整改项。没有发现遗漏的待解决代码评论。

性能:本机收益成立,CI 整体收益仍须分开判断

本机匹配的 Darwin/ARM64 整包 race 测量:wall 442.54 → 316.61s(−28.46%),CPU −16.98%;但峰值 RSS +19.41%/约 617 MiB。footprint 降低不抵消 RSS 增加,不能宣称已完成降内存目标。

最新 Linux UT job 确认运行 head 2ae7dce,已成功;必需 CI 汇总、ARM SCA 和两个多 CN BVT 均通过。日志中的实际 UT 步骤计时如下(不是整个 job 起止时间):

指标 上一 head aaa02d 当前 head 2ae7dce
UT 步骤 real(包含该步骤的构建/调度) 70m59.976s 67m6.708s
pkg/embed 539.26s 559.52s
四个被优化 CDC roots 合计 183.09s 181.25s

这两个 CI 样本都已包含本 PR 的优化,不是优化前后基线;且 embed 本次更慢,不能从全量步骤下降推导出稳定、因果上的 Linux 提速。PR 正文的“新 head CI pending/unvalidated”现已过时;本评论提供最新状态。

建议:本 PR 可作为有明确边界的局部优化推进;不要据此宣称全量 racing 已达 600 秒或整体内存已下降。

@XuPeng-SH
XuPeng-SH merged commit d7752ff into main Oct 11, 2026
@XuPeng-SH
XuPeng-SH deleted the codex/ut-racing-systematic-20261011 branch October 11, 2026 01:20
XuPeng-SH added a commit that referenced this pull request Oct 11, 2026
## What type of PR is this?

- [x] Improvement
- [x] Test and CI

## Which issue(s) this PR fixes:

Related to #29562; follow-up to merged #29836. This does not close the
overall UT racing runtime goal.

## What this PR does / why we need it:

The parallel INTERSECT fixture currently performs a TN flush after each
of its 32 single-row INSERTs. Those RPCs are unnecessary for the
contract: each table needs exactly 16 physical objects/blocks, followed
by real two-CN parallel scans.

Use the existing CN workspace force-flush point only around
construction. Each autocommit INSERT writes one object. Keep all
physical-layout, remote-plan/mcpu, duplicate/NULL multiplicity,
operand-reversal and empty-result assertions. Acquire the point without
overwriting another owner, remove it before inspecting/querying the
fixture, and preserve the previously enabled fault registry and
unrelated points.

One test file changes. No production, CI/workflow configuration, fixture
topology, readiness deadlines, or test coverage changes.

### Validation

Darwin/arm64, Go 1.27.1, GOMAXPROCS=8, repository CGo test wrapper,
short, tags=matrixone_test, count=1:

- Whole `pkg/tests/dml` normal (`-vet=all`) and race: all original 44
root tests and leaf names pass, no skips.
- Incremental golangci-lint: 0 issues; repository molint, gofmt and diff
checks pass.
- Actual fixture restoration challenged with an initially
disabled/enabled registry, unrelated points, conflicting ownership,
cancellation and FailNow. Restoration was checked before outer cleanup.
Temporary evidence probes/hooks are excluded from this PR.
- Actual gpt-6.1-sol/xhigh design and final overall review: PASS (exact
delivered scope; same session 01a1288f-57a2-7d70-9b24-61c3122b076d)..

### Local race measurements

Matched whole-package binary measurements with `/usr/bin/time -l`,
identical base/native inputs/flags and no contending tests/static scans:

| Metric | Before | After |
|---|---:|---:|
| Whole DML wall | 120.62 s | 104.62 s (−13.27%) |
| INTERSECT root | 18.45 s | 1.10 s (−94.04%) |
| Whole DML CPU | 110.58 s | 110.00 s |
| Peak RSS | 2,298,560,512 B | 1,827,487,744 B |
| Peak footprint | 2,691,207,224 B | 2,624,540,536 B |

An additional temporal-concurrency candidate was measured and discarded:
its small variable incremental benefit did not justify the added
executor/session machinery. The delivered change is byte-identical to
the measured INTERSECT-only variant.

These are local observations; Linux CI runtime and memory improvements
remain to be measured. No claim that the whole CI racing target is
complete.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
ci — 95eb63a2 Deployed Oct 11, 2026 by XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/enhancement kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants