Skip to content

[Task]: Continuous engineering quality: code reduction, design simplification, and test deduplication #29249

Open

Description

@XuPeng-SH

Why do you want to refactor this code?

Establish a long-running MatrixOne engineering-quality task for small, focused cleanup PRs submitted daily or nearly daily. The goal is to reduce system complexity, maintenance burden, and test cost rather than continually adding patches, frameworks, and overlapping tests.

The absence of a runtime bug does not justify retaining unused state, duplicate implementations, low-value test combinations, or obsolete paths left behind after fixes. These should be removed based on evidence. Conversely, code quality must not be judged by line count or test count, and necessary safeguards must not be weakened merely to achieve net deletions.

This is an ongoing tracking issue, not a task completed by merging a single PR. The repository has no dedicated Task template, so this issue follows the Refactoring request template.

Describe the solution you'd like

Scope

  1. Code removal: Remove dead code, unused fields/parameters/enums, redundant computations, abstractions without consumers, and historical compatibility paths whose retirement conditions have been met.
  2. Consolidated ownership: Reuse canonical implementations, fix shared root causes, and merge duplicate branches instead of maintaining separate rules at each caller. When a new implementation replaces an old path, explicitly identify when the old path can be removed.
  3. Simpler design: Review overengineering, speculative extension points, frameworks without demonstrated needs, and duplicate state. Prefer local, readable, verifiable implementations.
  4. Test quality: Cover unit, planner, protocol, operator, integration, and BVT tests. Assign distinct contracts and failure mechanisms to each layer; remove or replace low-value duplication and unnecessary Cartesian products. Avoid repeatedly testing the same entrypoint, data, and assertion across layers.
  5. Root-cause coverage and completeness: Check whether fixes address related callers, lifecycle boundaries, and sibling paths rather than merely special-casing a SQL shape or symptom. Tests should distinguish exercising the intended fix from obtaining the same result through another path.
  6. Cost and stability: Prioritize expensive duplicate cluster startup/execution, unnecessary waits, validation that continues after a campaign is already invalid, and fragile assertions coupled to internal call counts.

Acceptance criteria for each linked PR

  • Identify the reviewed baseline, scope, specific problem, and source/call-graph evidence; “optimize code” alone is insufficient.
  • Explain what is removed, consolidated, or replaced; which independent contracts remain covered; and why behavior is preserved or must change.
  • For test deduplication, provide a concise coverage mapping: which cases genuinely overlap and which retained cases detect each relevant failure mechanism.
  • When simplifying critical regression tests, use fix-reversion or mutation testing where appropriate to demonstrate continued sensitivity to the original bug. Do not mechanically add tests for deleting a purely unused field.
  • Run existing checks proportional to the risk. Do not claim speed, memory, or CI-time improvements without measurements; distinguish cluster startup cost from test execution cost.
  • Net line reduction is not a mandatory metric, but any new state, abstraction, hook, or test layer must explain why existing paths cannot serve the need.
  • Do not introduce production frameworks merely to simplify testing. Preserve necessary protocol-input, authorization, memory-ownership, version-compatibility, cancellation, and cleanup safeguards.
  • Keep PRs small, focused, independently reviewable, verifiable, and revertible. Do not bundle unrelated refactors into a daily PR.

Initial candidates

These candidates come from review of main at 66da3877e9e77f01083c4aac0cb9f94ab6e11fe6. Recheck current code before implementation; inclusion here is not blanket approval to delete code.

  • Unused state from perf(plan): eliminate bounded groups on not-null unique keys #29225: scanUniqueKeyProof.source, its enum, and assignments have no consumers. Remove the unused information while preserving the semantic restrictions required for unique-key proofs.
  • Test responsibility split for fix: preserve prepared INSERT SELECT assignment types #29169: The Go integration test and BVT overlap at the SQL PREPARE entrypoint. Consider replacing the Go prepared branches with actual binary prepare, retaining controls with and without secondary indexes rather than adding another near-duplicate test.
  • Low-value matrix reduction for feat(sql): support EXCEPT ALL multiset subtraction #29228: Review alias coverage multiplied across every dimension and repeated text execution without a distinct additional oracle. Preserve independent evidence for different set operators, LIMIT/pushdown boundaries, actual remote execution, and genuine prepared-statement reuse.
  • Retirement of superseded paths: For subsequent daily PRs, trace new implementations back to old implementations, callers, and compatibility branches. Remove old paths only after proving replacement relationships and retirement conditions.

Do not assume the following require changes:

Describe alternatives you've considered

  • Continually adding tests and defensive branches: Easy to deliver locally, but may increase maintenance cost without replacing root-cause fixes or obsolete-path removal.
  • Bulk deletion based on line count or similar SQL: Risks removing independent protocol, topology, and lifecycle guarantees. Inspect actual entrypoints, execution paths, and assertions first.
  • Building a universal framework before migrating existing code: Risks introducing more state and parallel paths. Prefer direct deletion, local consolidation, and replacement of existing tests; introduce abstractions only when actual consumers justify them.
  • Opening a separate issue for every small cleanup: Use this task for routine items. Track independent product bugs, high-risk design changes, and cross-team work in separate issues with cross-references.

Additional information

Activity

  1. self-assigned this
    on Sep 22, 2026
  2. changed the title [-][Task]: 持续工程质量治理:代码减法、设计收敛与测试去重[/-] [+][Task]: Continuous engineering quality: code reduction, design simplification, and test deduplication[/+] on Sep 22, 2026
  3. 69 remaining items

  4. XuPeng-SH commented on Oct 30, 2026

    @XuPeng-SH
    ContributorAuthor

    合并增量核对:#31933、#31934 已合入 main,但本 issue 是持续工程质量总项,不因单批 CI/生命周期/诊断改动整体转 QA。#31933 明确仍需分别处理 #31744、#31781、#31790、#31696、#31545、#31491、#30985;本轮保持研发负责人,不宣称这些独立缺陷已修复。本轮仅远端源码/评论静态核对,未运行新测试。

  5. XuPeng-SH commented on Oct 31, 2026

    @XuPeng-SH
    ContributorAuthor

    合并增量核对:#31488 已于 2026-10-31 04:02:23 UTC 合入 main,merge SHA 3f484ec428b2fdaeda333c82b8d562fdb5dbe71a。本批清理重复职责和未使用实现,并把未发布的 catalog 迁移收敛到 4.0.7/41;PR 明确保留本持续工程质量总项开放,因此保持 XuPeng-SH 负责,不整体转 QA。

    验证边界:PR 作者报告了 bootstrap/version 普通及 race 测试、升级/回滚/CDC 场景、发布版持久数据升级和 SIGKILL 恢复,以及最后 STATISTICS 测试修正的定向验证。这些是作者报告,本轮仅核对远端合并记录和完整 issue 评论,未运行本地测试;不能据此宣称全套回归、分布式或混合版本升级验收通过。

  6. XuPeng-SH commented on Oct 31, 2026

    @XuPeng-SH
    ContributorAuthor

    合并增量核对:#31942 已于 2026-10-31 12:10:42 UTC 合入 main,merge SHA ae40f12a647880a63466de32a9f507c2c72dca0b。本批修复 daemon claim/heartbeat fencing、CDC commit/SQL row 错误传播与暂停状态处理,并缩减部分重复测试。本 issue 明确为持续工程质量总项,因此继续由 XuPeng-SH 负责,不整体转 QA。

    尚未完成的开发范围:PR 与最终评审明确未宣称原 queued-pause/HAKeeper 超时已修复;旧 routine、替代 claim、legacy Publication 生命周期及共享 watermark 边界仍需安全修复,现存 CDC/generic status 并发和混合版本 stale writer 也不在保证范围。早先 scope review 异议已由 owner 的组合范围例外解决,不作为永久阻塞。

    验证证据仅来自远端作者/评审报告:taskservice、compiler、CN normal/race,planner/SQL integration normal,真实 driver claim、双 CN CDC 与 snapshot/publication race 及定向重复测试。最终评审未把完整 frontend normal/race 算作通过(只读 checkout 下既有测试写文件失败),外部 MySQL BVT、全量 CI 与性能提升亦未独立复现。本轮未运行本地测试,不作整体验收或生产/混合版本正确性结论。

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions