Skip to content

Reduce cancelled keepalive work and honor GC Bloom sizing - #30962

Merged
XuPeng-SH merged 6 commits into
mainfrom
codex/ut-plan-embedded-overlap
Oct 23, 2026
Merged

XuPeng-SH merged 6 commits into
mainfrom
codex/ut-plan-embedded-overlap

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 23, 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 issue #29249 (ongoing engineering quality and test deduplication task; this PR does not close it).

What this PR does / why we need it:

Reduce unnecessary work and memory in existing lockservice and GC paths, without removing test scenarios, weakening assertions, or splitting CI across runners.

Changes and responsibility

  • Stop cancelled keepalive rounds from issuing allocator refresh RPCs or logging cancellation as a remote failure. Preserve authoritative stale-bind invalidation. The common refresh owner also rejects an ended context before making an allocator call.
  • Route checkpoint merge and remaining-file GC Bloom filters through the existing configured row estimate and probability. These paths previously allocated for a hardcoded 10 million objects even when a smaller estimate was configured.
  • Normalize unspecified Bloom settings at their existing common construction function, and reject already-cancelled construction before allocation/buffer acquisition. Remove duplicated default handling from the GC job.
  • Set a 100,000-object estimate for small functional test fixtures through their existing configuration owners. Explicit embedded-fixture estimates remain intact; production defaults remain unchanged.

These Bloom filters are ephemeral. This does not change persisted data, checkpoint formats, or wire protocols. An estimate affects false positives and possible extra GC retention, not membership false negatives. Large-data/capacity fixtures can explicitly choose their estimate.

Evidence and limitations

  • The original keepalive path deterministically made 192 unnecessary GetBind calls across three cancelled rounds; the fix makes zero. Full lockservice normal UT (68.130s), racing UT (71.378s), focused racing repetitions, vet and incremental lint passed.
  • GC focused tests pass normally and under 100 racing repetitions. Full GC owning-package racing passes (36.786s).
  • Actual consumers pass with race enabled: pkg/backup (11.556s) and pkg/vm/engine/tae/db/test (79.903s).
  • Regression cases cover explicit/default Bloom settings, reader failure, cancellation before acquisition/during read, membership, buffer return, and mpool cleanup.
  • The real checkpoint/GC/restart branch scenario passes with race enabled (combined focused embed run: 46.953s). Heap allocation profiles show GC Bloom bitmap allocations falling from about 270 MiB to 10 MiB across its three construction paths. Total sampled allocation fell from 3165 MiB to 2896 MiB. These are cumulative allocation measurements, not a peak-memory or full-CI wall-time claim; elapsed time did not improve in this single local comparison.
  • Incremental golangci-lint passes with zero issues for lockservice, embed, GC and test configuration. Formatting and diff checks pass.
  • Synchronized with main e19f698. A concurrent remote merge had already incorporated the same main change; the local rebased tree was verified identical and the remote merge was preserved without overwriting it. The affected branch/checkpoint scenario passes again on this tree (44.674s). Other passing evidence above remains applicable to unchanged lockservice/GC inputs.
  • Full embed-package racing also passes on the synchronized head using the existing 8 batches / 4 workers: 143 root tests (141 pass, 2 existing skips), no duplicate roots, complete report validation, and no OOM. The 481s run validates fixture compatibility; it was concurrent with an unrelated cache-import experiment and is not a performance comparison.
  • No full local BVT or repository-wide UT racing run has completed for this combined head.

Overall CI optimization status

This is a bounded resource/correctness improvement toward the larger CI goal. It does not establish a ten-minute full-CI saving. Scheduling experiments were deliberately excluded: local overlap/pooling reduced elapsed time but increased CPU and peak memory. No scheduling changes or cache-import configuration changes are included.

Follow-up fixes and measured reduction

  • Reduce four GC failure fixtures from 300,000 objects each to one or two rows. Two early-failure scenarios force a real spill through the existing Sinker memory-threshold option; metadata-publication failures persist through Sync. Existing cleanup, retained-dependency, retry and error assertions remain.
  • Full GC racing inventory remains 113 cases. Sequential local 8-CPU/16-GiB/no-swap measurements: wall time 44.05s -> 2.06s; CPU 38.26s -> 0.63s; peak cgroup memory 2.15 GiB -> 157 MiB. These are package measurements, not a full-CI saving claim.
  • Release the other idle shared fixture before changing between one-CN and two-CN test helpers. Reject active callbacks or pending callback cleanup; retain failed-close ownership. Same-topology reuse remains unchanged. Focused lifecycle racing passed 100 repetitions.
  • Start transaction test operation deadlines after client setup; stop immediately when transaction creation fails. Full transaction-client racing passed.
  • Fix the latest CI cleanup failure in TestIssue29399AccountRestoreRollsBackInvalidPrivileges: reuse the existing resource-specific SQL cleanup policy (DROP ACCOUNT two minutes; other statements 30 seconds), moved into the existing shared test utility. Preserve bounded cleanup and residual-object assertions; no retries or permission behavior changes.
  • Before rebase, the real account-restore regression and independent/whole-account cleanup deadline tests passed with race enabled; incremental vet and configured lint passed for all eight affected packages (zero lint issues).
  • Rebased onto freshly fetched main 5fb586e. Post-rebase incremental vet and configured lint passed for all eight affected packages (zero issues). Racing validation passed for both cleanup-deadline families and the real account-restore regression (35.22s); both selected packages completed successfully. Full local repository racing/BVT has not been rerun for these additions.

Rejected higher-CPU/higher-memory worker-pooling and recovery-splitting experiments are excluded. No scheduler configuration changes are included.

Post-rebase whole-package racing also passed: lockservice 60.462s, transaction client 10.484s, GC v3 3.021s.

Scale-down regression readiness (final follow-up)

  • Fix the shared readiness gate for both three-CN DROP regressions. The test retires two owners, but previously observed eviction and allocator retirement only through mo_feature_registry. That single route cannot establish recovery for the other cached catalog routes used by DROP (including database defaults), especially across two membership removals and bounded keeper eviction rounds.
  • Capture catalog IDs and previously cached remote bindings before retirement. Require every catalog cache entry to be absent or point to the sole survivor, then verify TN retirement for the captured remote bindings. These probes do not publish CN routes. Keep the registry cold-route assertion and execute the first public DROP exactly once.
  • Keep existing one-minute/30-second readiness budgets. No SQL retries, sleeps, lock-service changes, fencing relaxation, or production-path overhead.
  • Before the fix, both original scenarios passed three local race-enabled repetitions each: the reported CI occurrence was not reproduced. This fixes a demonstrably incomplete readiness condition; it does not establish that the supplied CI failure has no additional product cause. A transaction touching an old bind is intentionally fenced after bind replacement, including in-flight admission intent; repeatedly retrying that same fenced transaction is not evidence that the new binding was never installed.
  • After the fix, both real three-CN scenarios again passed three repetitions each (six successful tests, owning-package command completed in 93.534s). Existing membership/eviction, cleanup and intent-fencing component tests each passed 20 race-enabled repetitions (3.370s owning-package command). Incremental vet and configured lint passed, zero issues. Validated source hashes match the delivered file.
  • No additional local full BVT or full-repository race pass is claimed. The unproven upgrade-batching candidate is excluded; its whole-stage comparison reused Go test results and is not valid performance evidence. No scheduler change is delivered.

@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 23, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: ee5cfe1e62f4223c068b49a82423ac33396ce645

Review completed. Read the assessment.

@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Oct 23, 2026

@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: ee5cfe1e62f4223c068b49a82423ac33396ce645

Assessment: approve

Reviewed the complete 10-file delta and affected owners/callers; no actionable findings remain. Cancellation handling preserves authoritative stale-bind fencing, and centralizing Bloom defaults removes duplicated policy while honoring configuration. Production defaults and explicit fixture overrides remain intact.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

Validation:

  • Verified clean frozen source, patch identity, formatting, native input provenance and library hashes. Owning-package go vet passed.

  • Full lockservice, GC and testutils/config packages passed normally and under race detection. Backup and storage/checkpoint/restart consumer packages passed under race detection.

  • Three focused regression tests each passed 100 race-enabled repetitions. Restoring the base keeper implementation reproduced the expected failure: 192 unnecessary allocator calls versus zero on the candidate.

  • Embedded validation covered all 143 listed root tests: 141 passed and two existing tests skipped. The initial run reached its five-minute package timeout; all 41 unfinished roots subsequently passed, including the changed fixture assertion. This was not a single uninterrupted package pass.

  • Constructor allocation probe measured 47,295,680 B/op with previous hardcoded settings, 1,760,442 and 3,767,482 B/op with fixture settings, unchanged allocation for production defaults, and zero allocation for cancellation before acquisition.

  • Reconciled 14 command/source/exit receipts with retained logs. Evidence mapping: /home/xupeng/.local/state/mo-bot/jobs/e22aca3d16b3eb78e098f6eb/attempt-1/validation-report.json; design and coverage map: review-scope.json in the same directory.

Limitations:

  • Frozen CI was pending and supplied no reusable local validation artifacts. No full-repository BVT or race-suite pass is claimed.

  • Existing skips remain: external-MySQL CDC integration, TestRestartCN and storage TestUpdate. Other relevant restart, GC and consumer tests passed.

  • Allocation measurements cover filter construction, not whole-checkpoint peak memory or full-CI savings. Underestimated Bloom capacity can increase conservative GC retention.

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

Incremental review of b903fae70c7590739d34b9ecb78f0594e61486dc: this commit moves the existing resource-specific SQL cleanup deadline policy into pkg/tests/testutils and reuses it from the SQL integration fixture and issue #29399 cleanup. The lexical handling (strings.Fields plus case-insensitive DROP ACCOUNT) preserves the prior 2-minute account / 30-second other-statement behavior; the existing synctest cases exercise mixed case/whitespace, timeout, and continuation to subsequent cleanup. I found no new defect in this extraction. I have not rerun these tests on this head in the current workspace; the PR description says post-rebase focused validation is still running, and the only workflow run currently visible is unrelated Iceberg Connector E2E. This is a comment-only review because this is the PR author's own change.

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

Incremental review of d0f726da83c687c2e1ffb8d9089b2661b885f01f: the new readiness gate checks every catalog ID's current cached route and separately resolves the captured remote binds, while keeping the mo_feature_registry route cold until the public DROP. I found one test-coverage gap: require.NotEmpty(cachedCatalogBinds) proves only that at least one remote catalog route was captured. Since the two departing CNs are retired afterward and both eventual loops iterate only the captured set, the test can pass without exercising a cached route owned by each departing CN. Please assert the captured bind set includes both non-survivor service IDs (and, if necessary, arrange/warm a catalog route for each) so this regression cannot silently collapse to a single-owner check.

Static review only; I did not execute MatrixOne tests in this workspace. PR description reports six passing three-CN scenario repetitions and 20 repetitions of component tests, but those are author-reported. At this head, GitHub checks remain in progress for CI preflight, Analyze (go), and Analyze (c-cpp); other completed checks include successful Java/Kotlin, JavaScript/TypeScript, Python, Actions analysis and Iceberg module tidy, while CodeQL/Mergify are neutral and Iceberg E2E is skipped. This is comment-only because the PR author is the contributor.

This branch was previously deployed

1 inactive deployment
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/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants