Skip to content

Fix daemon claim races and reduce redundant race-test work - #31942

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/ut-race-systemic-main-20261031
Oct 31, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/ut-race-systemic-main-20261031

Conversation

@XuPeng-SH

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

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG
  • Improvement
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Refs #29249

What this PR does / why we need it:

Scope: the owner explicitly requested one PR for the related UT-racing fixes and meaningful test optimizations (rather than separate small PRs). #29249 is referenced as the ongoing quality tracker; this combined scope follows that task-specific request.

The combined scope is an owner-approved exception to #29249's usual focused daily-cleanup PR rule. The independent test-only changes have these retained coverage boundaries:

Test optimization Retained contracts
DIV Full first-pass CTAS/view matrix, NULL and warning/error cases, integer boundaries and ODKU; a representative second pass with NO_UNSIGNED_SUBTRACTION, database recreation and teardown checks.
Planner witnesses All precisions 0–30 retain ALTER, candidate searches and exact-result checks; representative precisions retain cross-zone searches and the more expensive proofs.
Snapshot/publication Quoted database and publication names share an all-table case; explicit table-name quoting, empty-account/empty-table scopes and external-FK coverage remain.

The three test-only files have no implementation dependency on the daemon/CDC corrections and can each be restored to the PR base in a separate follow-up patch, with focused validation. This PR is delivered as one commit: reverting that commit rolls back all groups together. The owner accepts that combined review and rollback scope; the test optimizations do not extend the CDC correctness guarantees below.

CDC and daemon control can overwrite a newer owner or heartbeat, report success after a failed commit or partial SQL read, or publish Paused while a reader is still running. A queued daemon start can also claim a different generation, and using a logical claim timestamp for lease expiry can incorrectly steal a freshly renewed task when the previous timestamp is in the future.

  • Preserve lease fields during CDC status updates; fence generic daemon requests and new task admission by the observed claim. Use wall-clock time for heartbeats and expiry, separately from the increasing claim token.
  • Return CDC transaction commit and SQL row-iteration failures; retain Pausing and retry ownership when a reader has not stopped. Use the existing synchronized TaskService getter.
  • Reduce repeated DIV, snapshot/publication, and planner witness work while keeping the distinct SQL modes, publication scopes, precision boundaries, and exact-result assertions.

Local race comparisons (same machine and flags; individual test times, not whole-CI claims): planner witnesses 137.30s → 121.07s; DIV 35.97s → 30.53s and 31.45s → 26.53s; snapshot/publication 35.96s → 29.58s.

Existing validation (author-reported; not rerun for this metadata-only clarification):

  • Full race/short/tag runs for taskservice, frontend, sql/compile, cnservice, sql/plan and sqlintegration; embed full race passed before the final task-runner changes. After those changes, real CREATE/PAUSE/RESUME CDC, two-CN concurrent owner/heartbeat tests and the real driver claim tests passed under race. The external MySQL BVT requires its configured target and was skipped.
  • The affected packages passed selected molint/golangci SCA and go vet with the repository CGo setup. Fast concurrency/claim regressions passed 100 local race repetitions; the two-CN interleaving passed four.
  • Independent design and code review completed with gpt-6.1-terra/max. The new owner/heartbeat and logical-token scenarios were reproduced as failures before their fixes.

Remaining work: the original race CI failure still needs a safe fix. HAKeeper requests timed out while CDC pause was pending, but the exact blocking path is not proven. A queued pause can act on a replacement claim or old local routine; deterministic local reproductions cover foreign ownership and local object replacement. Simply rejecting the old routine can leave a legacy Publication executor running or its pause request permanently pending. Prioritizing the existing handler without first addressing ownership, lifecycle completion and shared watermark state can introduce cross-generation errors; this PR does not claim that issue is fixed. Existing concurrent CDC/generic status races and mixed-version stale writers also remain outside the guarantees above.

@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 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: ea1a38bfd2ea1af016aead6b58826e0c33cbc4bd

Review completed. Read the assessment.

@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.

mo-bot review · mo-bot-local · review

Commit: ea1a38bfd2ea1af016aead6b58826e0c33cbc4bd

Assessment: request_changes

One P2 scope-contract finding remains. Taskservice normal and race suites passed; source review found no additional demonstrated regression.

Model: gpt-6-astra / xhigh

Session: 01a1869d-820c-7212-9788-aecfb86a4141 · slot 0 · generation 2

  • P2 pkg/tests/sqlintegration/decimal_integer_division_test.go:28: This PR bundles daemon/CDC correctness fixes with independent DIV, planner-witness, and snapshot/publication test optimizations.
    Impact: The bundle violates the linked issue's focused-PR requirement and couples otherwise independent validation and rollback. This is a scope/design finding, not a demonstrated runtime defect.
    Evidence: Frozen linked issue #29249 requires independently reviewable, verifiable, and revertible PRs and explicitly says: "Do not bundle unrelated refactors into a daily PR." Changes in decimal_integer_division_test.go, float_string_scope_session_test.go, and snapshot_publication_replay_test.go have no implementation dependency on the daemon fixes. The frozen discussion records no scope exception. Separate these test optimizations into focused PRs.

Validation:

  • Reviewed the complete 25-file delta, affected owners and consumers, linked issue context, and both discussion entries; saved review-plan.md and discussion-assessment.json.

  • Isolation preflight passed. Native reuse was qualified against 193 current input hashes and 13 output hashes.

  • Taskservice normal suite passed: 255 top-level tests, zero skips, -short -tags=matrixone_test -count=1 with assigned test-exec. Receipt: checks/1793416735230184211-3.json; log: taskservice-normal.jsonl.

  • Taskservice race suite passed with the same selection: 255 top-level tests, zero skips. Receipt: checks/1793416840275487741-3.json; log: taskservice-race.jsonl.

  • Final receipt/log audit passed and confirmed the exact head and unchanged source. Receipt: checks/1793417016499380609-3.json; report: validation-audit.json.

Limitations:

  • Broader frontend, compiler, CN, embed and SQL integration execution was deferred after the scope finding; source review does not constitute full runtime validation.

  • Author-reported broader tests and performance improvements were not independently verified. Frozen CI includes incomplete and cancelled checks.

@XuPeng-SH

XuPeng-SH commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: e5acebd109b8394a659535e8399c12afb603b5a3

Review completed. Read the assessment.

@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.

mo-bot review · mo-bot-local · review

Commit: e5acebd109b8394a659535e8399c12afb603b5a3

Assessment: approve

No actionable regressions found. Claim fencing, CDC failure handling and retained test coverage are coherent. The explicit tracker-owner exception resolves the previous scope objection.

Model: gpt-6-astra / xhigh

Session: 01a1869d-999c-7481-b340-ae4a63e8cee4 · slot 1 · generation 2

Validation:

  • Reviewed all 25 changed files and reconciled all four discussion items.

  • Taskservice, compiler and CN-service suites passed normal/race checks; planner and SQL integration suites passed normal checks.

  • Real-driver daemon claims, two-CN CDC concurrency and snapshot/publication tests passed under race detection.

  • Four focused claim/lifecycle tests each passed 100 race repetitions. All affected frontend tests passed.

  • Go vet passed all seven affected packages. Preflight, native provenance and source cleanliness verified.

  • Commands, exits, source fingerprints and retained logs reconciled in /home/xupeng/.local/state/mo-bot/jobs/df786e86cf8c52d4ce9c1fbe/attempt-2/validation-audit.json.

Limitations:

  • Full frontend normal/race runs failed solely because unchanged Test_openNewFile_nilCtx writes into the read-only checkout; neither package run is counted as passing.

  • External MySQL BVT, full CI and reported performance improvements were not independently reproduced.

  • The acknowledged historical queued-pause/HAKeeper issue is not declared resolved.

This branch was successfully deployed

No deployments
ci — 06e0469f Deployed Oct 31, 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/refactor Code refactor kind/test-ci size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants