Skip to content

fix(disttae): prune unflushed composite CLUSTER BY reads in CN logtail replay state - #30617

Merged
mergify[bot] merged 9 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-26996-af028d20
Oct 22, 2026
Merged

mergify[bot] merged 9 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-26996-af028d20

Conversation

@gouhongshen

@gouhongshen gouhongshen commented Oct 19, 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 to #26996

What this PR does / why we need it:

Composite CLUSTER BY predicates previously scanned every committed, unflushed CN replay row. Reuse the existing serialized-key predicate extraction and MVCC visibility owner with an optional nonunique candidate index; both local and materialized committed readers consume it. Unique-PK stopping and persisted-object pruning retain their existing owners.

Rebased onto main 9f7fe43649: the mid-2026-10-22 main advance (c0e826888b, upstream's own smaller fix to the same publication_test.go test) made the branch CONFLICTING, so the branch was rebased again (verified-reason base update for the actual conflict); the single-file overlap was resolved to the restart-based fixture test, which upstream's in-place change also converges toward. The eight feature/test commits replayed; the drain fixture patch is identical to its reviewed content. The additional lockservice test correction fixes the CI race caused by mutating a live allocator epoch: restart scenarios now replace the allocator through the existing fixture owner, preserving construction unwind and teardown ordering. The coverage-UT lane then exposed the same fixture's second restart-window defect (run 39728200972, job 119657029775, TestGetBindPurgesStaleBindWhenAllocatorIDChangesWithRegressedVersion: the first post-restart get-bind wrote into the pooled rpc connection the closed allocator had just severed, write: broken pipe). Restart now drains every service's stale pooled allocator backend between the old allocator's close and the replacement's construction, using dead-path get-bind probes that cannot reach a server and complete only on the dialer's ErrBackendCannotConnect verdict, so the first scenario RPC after restart dials the listening replacement. The delayed publisher is released and joined on early exit; drain recovery waits for successor-generation observation before the fresh handshake. No production lock protocol or hot-path synchronization changes. The feature revision addresses both reviews on bcb956d421:

  • Admit only the actual declared hidden VARCHAR cluster column. Capture a scoped, immutable schema descriptor at the serialized dispatcher after catalog application and before queueing table work. Unknown/bootstrap/historical schema intervals fail open; legal VARCHAR prefix shadows never create an unused index.
  • Check eligibility before encoding; sticky-disabled/noData states retain no cluster tree. Derive GC keys from the retained batch at all four removal boundaries, removing the global per-row key slice. Clone published row entries before replacement, including same-timestamp insert/delete cleanup; old snapshots remain immutable.
  • Bound candidate preflight without visibility lookups. Broad predicates use the existing exhaustive iterator plus residual SQL filtering; selective predicates use the index. Exclusive lower bounds seek past excluded duplicate runs. No additional cache, worker, wire identity or persisted format.
  • Remove unused primary-iterator test counters/wrappers; share replay batch setup. Functional fixtures use 64 real-TAE rows with small blocks, a six-row public SQL test, and 12 SQL BVT rows. Scale belongs to benchmarks. Coverage retains duplicates, MVCC/deletes, NULL components, schema fallback, snapshot/COW, transport-buffer reuse, flush/GC and mixed persisted/replay reads.

Design: versioned revision 3 (document content is unchanged by this rebase and test correction). gpt-6.1-sol / xhigh design approval, session 01a156e9-7d52-7913-9900-e06502c7c49e: rev2 exact reviewed hash fa3ac0adde617b2e1b1801127845f97d52bc4743e49337b454cabdf999e7a503; bounded-selection rev3 hash 339e976b9e8ace0071cda93f284e5573724d83ab292d0043e8d0a1e87251df19. Status/implementation-cost clarifications are recorded separately in the document. Final overall review: GO, no unresolved material blockers, gpt-6.1-sol / xhigh, session 01a15720-633a-7bd1-b65d-0353ecea797e, exact commit 57a03a91bfcac09da7a41683ac37d0a612aa04a2.

Current-revision local validation (Go 1.27.1, macOS arm64, matching native inputs/artifacts):

  • Lockservice owning package normal and race; ten restart/cleanup tests each pass -race -count=100, including the original CI test. Exported helper consumer TestCheckLockTableBindsChangedWithStaleLocalCache passes normal and race.

  • Allocator-restart drain correction (commit a1a4ce7f6f, newest head;2b7800998c before the final rebase, patch identical): the drain contract is held synchronously (TestRestartDrainsStaleAllocatorConnections) and per leg (TestDrainUntilProbeDialsLegSemantics: severed-write and backend-closed legs retry, the dial verdict completes the drain, a probe reaching a live allocator errors, persistent failures stop at the bounded deadline). All nine restart scenarios plus both drain tests pass -count=10; the owning package passes normal (60.0s) and race (64.8s); the restart family passes -race -count=20; after the final conflict rebase the restart family and drain tests pass -count=2 on the rebased tree.

  • Fixture correction design and final review use gpt-6.1-sol / xhigh; design session 01a161bb-1865-70b3-bb43-5a85e17dcf6a, review session 01a161c9-320f-72f3-bf73-e5a31a4f5ae2. The first review identified the post-restart heartbeat assumption; the final revision closes it and retains the safety assertions. Final overall review: GO, no material blockers, exact commit db727173a072a5eaf14981006bd18fcd6cf58329.

  • Complete disttae/replay/readutil/catalog owning packages normal and race; affected planner/dispatcher/command lifecycle tests normal and race.

  • Real MySQL SQL test normal and race: selective query returns count=2/sum=39 with actual scan=2; broad query returns count=4/sum=46 with actual scan 6→4 and zero object reads. This proves real metadata admission and fallback residual filtering.

  • Official mo-tester normal comparison, 37/37 twice on the same embedded instance with final selection policy; no generated expected-result acceptance.

  • Seven-package incremental gofmt/vet/molint/configured golangci-lint: no new findings. Build passes for six runtime packages; sqlintegration is test-only and is compiled and executed by the normal/race SQL tests. Existing feature molint advisories remain outside changed lines.

Performance is not free. Historical measurements of the approved feature revision 57a03a91bf against base c7bd2e7c1d9ca53daf80d640b3b307902d54161c: three serial interleaved base/head samples on Apple M4 (100 ms/sub-benchmark, GOMAXPROCS=4), same fixtures/workload. This rebase/test-only correction does not claim new benchmark measurements:

Workload Measured median result
Ordinary plain/shadow/disabled replay Within 5% budget; fresh ordinary RowEntry remains 112 bytes, no per-row index field
100k rows, two matches Exhaustive 1.29 ms → indexed 1.13 us; iterator microbenchmark, not end-to-end SQL latency
Broad / duplicate-heavy +8–13% at 100k; prior unconditional-index ~30x regression eliminated
Partial / overlapping broad intervals +2–9%
Active narrow-key replay / GC ~1.44–1.50x / ~1.65x base
4 KiB active keys: insert / GC / held-snapshot replay ~2.9x / ~3.5x / ~3.3x base; key-width cost is explicit

Narrow active index adds about 146 Go bytes per retained version. Ordinary duplicate replay with an old snapshot held additionally retains a private ~112-byte RowEntry (a correctness repair for the old in-place mutation); active held-snapshot delta is ~251 bytes/version. Wide-key paired sizing estimate is about 5 KiB/version; absolute wide-key heap subtractions show fixed cache-lifetime bias and are not RSS/cgroup capacity claims. Native scratch packer high-water is 4 KiB narrow / 16 KiB wide, reused per operation. Replay memory therefore depends on key width and snapshot/version retention.

Scope accounting against the rebased base: implementation 13 files +925/-147; tests 13 files +5144/-104; design 1 files +279/-0; allocator-restart drain fixture correction +188/-0 across pkg/lockservice/test_helper.go and pkg/lockservice/test_helper_test.go. Smaller fixture data is a runtime-cost reduction, not a claim that test lines disappeared. No full repository CI was run locally; post-push CI remains pending. Historical green CI on a previous head is not claimed for this revision.

@mergify mergify Bot added the kind/bug Something isn't working label Oct 19, 2026
@matrix-meow matrix-meow added the size/XXL Denotes a PR that changes 2000+ lines label Oct 19, 2026
@gouhongshen

gouhongshen commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

CI and merge-queue blocker record for PR #30617 — after the single permitted failed-jobs rerun of head-rebase run 39697425477 reached its terminal state at 2026-10-22T02:04:37Z (attempt 2, conclusion failure), the then-unresolved item was a detected data race in the pkg/lockservice unit test TestPublicationSurvivesAllocatorRestart, repaired for this PR on 2026-10-22 by maintainer commit db727173a0, whose restart scenarios replace the allocator fixture instead of mutating a live epoch (item 6, resolved for this PR); the same rerun resolves the earlier runner-network checkout blocker of #28113 (item 5): both rerun jobs completed actions/checkout, SCA reached terminal SUCCESS, and the UT job executed the full test set and failed only on that single unrelated test. The earlier Mergify workflows-permission blocker no longer applies to this PR after its head was rebased onto current main (item 4). The first CI round on the repaired head (run 39728200972, attempt 1) then exposed a second restart-window defect in the same new fixture on the coverage lane — item 7 — which was caused by this PR's own diff and was fixed in commit 2b7800998c (rebased to a1a4ce7f6f after the mid-round main advance conflicted in the same file; patch identical) before any rerun.

  1. RESOLVED — Matrixone CI execution / UT Test on Ubuntu/x86 (and the CI Required aggregate that follows it), tracked in [Bug]: UT Test on Ubuntu/x86 fails TestIssue29133RoleRulesTrackRemoteChanges with bad connection during harness fixture teardown #30657. Original hit: on the current head dc0ead1462, run 39379852775 completed its UT job 118486280660 in terminal failure at 2026-10-20T07:11:11Z with FAIL_UT_CASES=TestIssue29133RoleRulesTrackRemoteChanges, — the only failing test in the entire run (UNIT TESTING FAILED: go-test=1, analysis=0); the required-check aggregate job 118506639846 then failed on the same rollup. The failing statement is the test's cleanup helper at pkg/tests/issues/issue_29133_policy_refresh_test.go:41 (t.Cleanup on db.Close()), which received bad connection from a connection severed by the surrounding harness teardown: at the same wall-clock second the job log records the account-10003 connection-kill storm around a CDC do_update_task CancelRequested, MO_UT_SETUP fixture=shared-cluster phase=failed-test-seal generation=1, and MO_UT_SETUP fixture=embedded-cluster cluster_id=12001 pid=108113 phase=service-close ... hold=1m32.76s, on a runner under memory pressure (heartbeat peak 17.18 of 17.18 GB, ~243.3 s CPU throttling, 17+ live test processes). The test was introduced by the frontend role-rules fix fix(frontend): refresh role rules across CN sessions #30400 (7d93ece829); this PR's 22-file diff contains no pkg/tests/issues, frontend, CDC, or harness file, and everything this PR does change is green in the same run — including this PR's own regression TestClusterReplayPublicAdmission (pass, 0.73 s) plus the SCA Test on Linux/arm64 job that previously blocked this PR (terminal SUCCESS, 1h2m27s). The same heavy-UT lane had already failed the earlier head 57a03a91bf with a different unrelated test (TestCheckConstraintNamespace), which the owner review of this PR verified passing on both that head and the clean merge base with all 18 scenarios green, so the lane's failures move between unrelated, load-sensitive tests while the PR-owned surface stays green. Full mechanism evidence and reproduction record: the initial record of [Bug]: UT Test on Ubuntu/x86 fails TestIssue29133RoleRulesTrackRemoteChanges with bad connection during harness fixture teardown #30657 (sampled from the failed job's raw log, with the no-local-reproduction limitation stated explicitly). Resolution verified: the single permitted rerun of the failed jobs (gh run rerun 39379852775 --failed) requested at 2026-10-20T08:16:52Z produced run 39379852775 attempt 2 (run_started_at 2026-10-20T08:16:59Z), which reached terminal state at 2026-10-20T09:12:39Z with run conclusion SUCCESS. In that terminal attempt the rerun UT job 118526411262 executed 08:33:09Z–09:12:31Z with terminal SUCCESS, and the required aggregate job 118548693616 completed terminal SUCCESS at 09:12:38Z; the lane fails its UT job on any nonempty FAIL_UT_CASES (as the original hit demonstrated), so attempt 2 ran the UT set green on the exact head dc0ead1462. That is the recorded removal condition, so [Bug]: UT Test on Ubuntu/x86 fails TestIssue29133RoleRulesTrackRemoteChanges with bad connection during harness fixture teardown #30657 is removed from the unresolved list.

  2. RESOLVED — Matrixone CI execution / UT Test on Ubuntu/x86, tracked in [Bug]: Ubuntu race UT cancellation/running harness times out with live fixture processes #30309. Original hit: TestEmbeddedPrebuiltExecutionCancellation/running in optools hit the fixture's 15-second harness deadline (runner harness timed out: exit status 92) in run 39298736197 (head 9688619d74); reproduction record: [Bug]: Ubuntu race UT cancellation/running harness times out with live fixture processes #30309 (comment). This PR touches no optools or runner file, and the optools fixture imports none of the changed code. Resolution verified: on the then-current head 4a87cdc39e, run 39309086741 completed UT Test on Ubuntu/x86 with terminal SUCCESS at 2026-10-19T19:58:40Z (job 118253835970), alongside terminal CI Required SUCCESS, so this blocker was removed from the unresolved list.

  3. RESOLVED — Matrixone Utils CI / pr-size-label, tracked in [Bug]: pr-size-label fails when the runner proxy drops the GitHub API TLS connection #27127. Run 39309086741 attempt 1 (head 4a87cdc39e) failed job 118253836049 with the known proxy/TLS drop: the shared label-size-action (from the external matrixorigin/CI repository, behind runner proxy http://proxy-service.proxy.svc.cluster.local:8001) aborted before classification on ##[error]request to https://api.github.com/repos/matrixorigin/matrixone/pulls/30617/files failed, reason: Client network socket disconnected before secure TLS connection was established; reproduction record: [Bug]: pr-size-label fails when the runner proxy drops the GitHub API TLS connection #27127 (comment). Resolution verified: once the run reached its terminal state at attempt 1 (completed 2026-10-19T20:09:08Z, no earlier rerun), the single permitted rerun of the failed job was requested (gh run rerun 39309086741 --failed) at 2026-10-19T21:38:57Z; rerun job 118322590980 completed SUCCESS at 2026-10-19T21:39:35Z — the labeler fetched the changed-file list (additions 5443, deletions 133, changedSize 5576), found the size label already correct, and finished normally, so the network drop affected only that one labeling request. Run 39309086741 is terminal at attempt 2, conclusion SUCCESS, with zero failing checks on the PR at that time.

  4. RESOLVED FOR THIS PR (2026-10-22) — Mergify merge queue could not update this PR while the GitHub App lacked the workflows permission, tracked in [Bug]: Mergify queue cannot update workflow without workflows permission #27185 (org-level issue still open; same refusal on fix: generate valid CLONE SQL in async Python SDK #27177 and fix: preserve SIGN numeric type in prepared statements #28636). This is merge infrastructure, not a MatrixOne CI or code failure: all exact-head CI checks for this PR are terminal SUCCESS (run 39379852775, attempt 2), reviewDecision is APPROVED, and the PR is MERGEABLE and behind only by ordinary freshness. Occurrence: the main queue rule Automatic queue on approval for main admitted the PR at 2026-10-20T09:34:31Z, dequeued it at 2026-10-20T13:33:16Z at head dc0ead1462 after 3h58m39s with no time running CI, and its queue check Rule: Automatic queue on approval for main (queue) concluded FAILURE. Mergify's status comment records the exact response: refusing to allow a GitHub App to create or update workflow .github/workflows/tpch-compare.ymlwithoutworkflows permission, with the recovery pointer that an organization owner can accept Mergify's pending permissions at https://dashboard.mergify.com/orgs/matrixorigin/repositories. Mechanism verified locally from a clean checkout of the PR branch: main commit 7c146f4adb (2026-10-20, feat: add native TPC-H workload tools for MO and DuckDB #30588) ADDED .github/workflows/tpch-compare.yml after this PR's merge-base c7bd2e7c1d (git merge-base HEAD origin/main → c7bd2e7c1d9ca53daf80d640b3b307902d54161c; git diff --name-status <merge-base> origin/main -- .github/workflows/ → A .github/workflows/tpch-compare.yml), while this PR's own diff touches no .github/workflows/** path (empty path diff merge-base→head). Every queue update of this PR must therefore create that workflow file branch-side, and GitHub refuses that write for a GitHub App without the workflows permission, so the failure is deterministic until the pending permission is accepted; any PR based before 7c146f4adb queuing for main is in the same position. New-occurrence evidence for this queue hit posted to [Bug]: Mergify queue cannot update workflow without workflows permission #27185: [Bug]: Mergify queue cannot update workflow without workflows permission #27185 (comment). Recovery: no code change, head change or CI failed-job rerun applies — the failing check is the queue rule itself. An organization owner must accept Mergify's pending workflows permission at the dashboard above; afterwards the PR is requeued for its automatic update (@mergifyio queue, after which Mergify updates the branch and runs the queue's own fresh CI). No requeue was requested this round: as of 2026-10-20T13:43Z no evidence of a permission acceptance exists on the PR timeline and [Bug]: Mergify queue cannot update workflow without workflows permission #27185 remains open/needs-triage, so requeuing would deterministically reproduce the same refusal. Mergify's alternative hint (update or rebase the PR manually) is intentionally not taken — per this loop's policy the update stays with the merge queue, the head dc0ead1462 is left unchanged, and no .github/workflows/** file is touched. This PR remains ready to retry after the permission fix: APPROVED, all required checks green, MERGEABLE.

Resolution evidence for this PR (2026-10-22): repo maintainer XuPeng-SH force-pushed the rebased head c5bf41ded3557a2cc7cd898a470cee8fa1dd5a8d at 2026-10-22T00:04:20Z onto the current main tip 0276f82fb7 (verified as the merge-base), whose history contains the .github/workflows/tpch-compare.yml addition 7c146f4adb that made every earlier queue update of this PR require a workflow-file write. The rebase preserves the PR patch (same 22-file, +6100/-137 delta versus the merge-base, byte-identical design document, same six commits by subject), so the approved implementation and the recorded reviews still describe this head, and reviewDecision remains APPROVED. The queue check created after the push started and completed 2026-10-22T00:04:59Z with CANCELLED — no new workflows-permission refusal occurred on the new head — and Mergify's 2026-10-20 status comment already stated this PR requeues automatically once queue conditions match again. The org-level permission gap itself stays tracked on #27185 for other PRs based before 7c146f4adb; no recovery action on this PR remains.

  1. RESOLVED FOR THIS PR (2026-10-22) — the Matrixone CI execution / UT Test on Ubuntu/x86 and Matrixone CI execution / SCA Test on Linux/arm64 jobs of attempt 1 failed inside actions/checkout on runner-network GnuTLS terminations — run 39697425477 attempt 1, head c5bf41ded (first CI run on the rebased head), tracked in CI: Ubuntu UT checkout intermittently fails with GnuTLS handshake error #28113, occurrence record: CI: Ubuntu UT checkout intermittently fails with GnuTLS handshake error #28113 (comment). Both jobs exhausted the three checkout retries of git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=3 origin c5bf41ded355… from https://github.com/gouhongshen/matrixone/ with gnutls_handshake() failed: The TLS connection was non-properly terminated. (UT job 119558183752, terminal failure 2026-10-22T00:08:47Z; SCA job 119558183672, terminal failure 2026-10-22T00:09:35Z), so no build, analysis, or MatrixOne test executed — the UT recovery step logged No raw UT report was available for diagnostic recovery. This is the exact checkout signature already recorded in CI: Ubuntu UT checkout intermittently fails with GnuTLS handshake error #28113 (original hit: PR perf: add cost-based hash partition for windows #27972 on the iamlinjunhong fork) and is unrelated to this PR's diff: the PR sources never reached the runner, other jobs of the same run on the same head (Shared Build, CI preflight, pr-size-label, coverage eligibility) are terminal SUCCESS, and this PR's identical patch already passed the full required CI at run 39379852775 attempt 2 (conclusion SUCCESS, 2026-10-20). Recovery (no code change applies): the run reached its terminal state at 2026-10-22T00:57:49Z (attempt 1, completed, conclusion failure), and every later-finishing job of the same attempt is terminal SUCCESS on head c5bf41ded — UT Coverage on Ubuntu/x86 (job 119558214173, 00:39:02Z), multi-CN BVT PESSIMISTIC (job 119560758982, 00:44:55Z), multi-CN BVT PROXY (job 119560758985, 00:56:43Z), Coverage (job 119575570700, 00:57:41Z) — so attempt 1 independently re-confirms that only the two checkout-killed jobs (and the CI Required aggregate rolling them up) failed, while this exact head's sources built and passed coverage-UT and multi-CN BVT in the same run. The single permitted failed-jobs rerun gh run rerun 39697425477 --failed was then requested at 2026-10-22T01:06Z, moving the workflow to attempt 2 (run_started_at 2026-10-22T01:06:14Z, queued then in_progress). Attempt-2 resolution evidence (2026-10-22): the single permitted rerun did not reproduce the checkout failure — both rerun jobs completed actions/checkout and executed their configured work: SCA job 119578690094 reached terminal SUCCESS at 2026-10-22T02:04:27Z (the check that previously blocked this PR), and UT job 119578690436 ran the full unit-test set 01:06:29Z–01:55:26Z with zero fetch failures. The run is terminal at attempt 2 (completed, conclusion failure, updated 02:04:37Z) with the UT job failing on exactly one case — FAIL_UT_CASES=TestPublicationSurvivesAllocatorRestart,, new item 6 — and the CI Required aggregate job 119596648101 rolling up exactly that failure at 02:04:36Z. The checkout-GnuTLS signature has therefore not recurred since attempt 1, so CI: Ubuntu UT checkout intermittently fails with GnuTLS handshake error #28113 is removed from the unresolved list (org-level runner-network tracking stays with that issue).

  2. RESOLVED FOR THIS PR (2026-10-22) — Matrixone CI execution / UT Test on Ubuntu/x86 failed on a detected data race in TestPublicationSurvivesAllocatorRestart, a pkg/lockservice test upstream added to main one day before this PR's rebase — run 39697425477 attempt 2, head c5bf41ded, job 119578690436; no existing issue tracks this race. The rerun UT job executed the full set 01:06:29Z–01:55:26Z and failed on exactly one case: --- FAIL: TestPublicationSurvivesAllocatorRestart (1.61s) preceded by WARNING: DATA RACE and closed by testing.go:1865: race detected during execution of test, so the lane reported UNIT TESTING FAILED: go-test=1, report=0, analysis=0 and FAIL_UT_CASES=TestPublicationSurvivesAllocatorRestart, — the only failing test in the entire run — with the CI Required aggregate failing at 02:04:36Z. The raw race record: the test goroutine (17684) writes at pkg/lockservice/publication_test.go:118 — alloc.version++ inside the test's simulated allocator restart, taken under alloc.mu — while the previous read of that same allocator field by goroutine 17690 happened in (*lockTableAllocator).handleKeepLockTableBind at pkg/lockservice/lock_table_allocator.go:1616 (confirmPendingDrainHeartbeat(req.KeepLockTableBind, l.allocatorID, l.version), with the sibling unlocked read resp.KeepLockTableBind.AllocatorVersion = l.version at line 1599), none of them held under l.mu. Every racing frame is upstream-tree code: the mutating test is from 04fe057bd7 (Lundomn, upstream fix(frontend): publish DUMP archives with create-only storage writes #29808, merged 2026-10-21T04:19:58Z; absent from the previous merge base c7bd2e7c1d, it first entered this branch through the maintainer's rebase onto main tip 0276f82fb7), and the handler read lines are from upstream history around the test's introduction (blame a1220dec7, 2026-09-20; 5e965dece9e, 2026-10-04). This PR's 22-file diff touches no lockservice, fileservice or common file, and the failing test package's full dependency closure matches none of this PR's changed packages (go list -deps -test ./pkg/lockservice contains none of pkg/vm/engine/disttae, pkg/vm/engine/readutil, pkg/sql/plan, pkg/tests), so the raced test binary is compiled from code identical to a pristine 0276f82fb7 checkout; the same run's attempt 1 already proved this exact head's sources green on UT Coverage, both multi-CN BVTs, Coverage, Shared Build, pr-size-label and CI preflight, and attempt 2 adds SCA terminal SUCCESS. Bounded local verification on the exact worktree head c5bf41ded3 could not reproduce the race on an idle machine: with the CI's own race configuration (go test -mod=readonly -vet=off -short -race -tags matrixone_test), -count=10 and then -count=100 repetitions of ^TestPublicationSurvivesAllocatorRestart$ in ./pkg/lockservice both PASS with zero race reports (evidence logs /tmp/pr30617-local-race1.log, /tmp/pr30617-local-race2.log); the failing CI moment sits inside a heavily loaded runner window (light-race-batch heartbeat at the failing timestamp: 19 live test processes, memory current 13.4 GB of the 17.18 GB peak, ≥506 s cumulative CPU throttling), the scheduling spread a narrow race window needs — so the CI record stands as the only reproduction and the race is load-sensitive, not deterministic. No matching existing issue was found and current main carries no fix to incorporate (c232b6d2a1, Fix mixed JSON and numeric comparisons #30707 and 460b96365a, fix(load): restore sampling context and make CN PK checks opt-in #30697 are the only commits after this base, neither touching lockservice or fileservice); fixing upstream lockservice code inside this PR is out of scope — therefore this round edits no code, requests no rerun (run 39697425477 is at attempt 2 — its single permitted failed-jobs rerun was already used), creates no issue, invents no marker entry, and makes no base update. Recovery belongs to upstream ownership of fix(frontend): publish DUMP archives with create-only storage writes #29808's test/handler code (read l.version under l.mu in handleKeepLockTableBind, or serialize the test's restart mutation with that handler); once such a fix lands on main it becomes a verified-reason rebase for this PR, and until then item 6 stays unresolved, with the queue's fresh CI on the next requeue as the retry path for this load-sensitive race.

Recovery performed in the 2026-10-22 rebase-head CI rounds: (1) inspected both terminal failures of run 39697425477 attempt 1 from the raw job logs — both are actions/checkout fork-fetch GnuTLS terminations with all three fetch attempts exhausted per job and no code executed; the failure is runner infrastructure matching existing issue #28113, and the occurrence record was posted there (no new issue created). (2) Recorded the item-4 resolution evidence: maintainer XuPeng-SH rebased this head onto current main at 2026-10-22T00:04:20Z (patch unchanged), clearing the workflows-permission trigger for this PR; today's queue check concluded CANCELLED with no permission refusal. (3) No code, head, or base change is involved in either round: the local worktree stayed aligned to the pushed head c5bf41ded3. The first round could not rerun while run 39697425477 was pending (UT Coverage and BVT jobs); this round re-verified both terminal failures from the raw job logs (UT job 119558183752: two gnutls_handshake() failed: The TLS connection was non-properly terminated. lines and zero go test/UNIT TESTING/RUN_TEST lines, so no MatrixOne test ran; SCA job 119558183672: the same fatal at 00:06:23Z, 00:07:55Z and 00:09:28Z, all three fetch attempts exhausted), confirmed the run terminal (attempt 1 concluded at 2026-10-22T00:57:49Z), requested the single permitted failed-jobs rerun at 2026-10-22T01:06Z (attempt 2, run_started_at 2026-10-22T01:06:14Z), and does not await the remote rerun's terminal state in this round. The attempt-2 outcome above supersedes the removal sentence of the rebase-head round: the checkout failure did not recur on the retry (both jobs got past checkout), the lane's remaining failure is the separate item-6 race, and item 5 is therefore resolved for this PR.

Recovery performed in the 2026-10-22 attempt-2 round: (1) retrieved the terminal attempt-2 state of run 39697425477 (completed, conclusion failure, updated 02:04:37Z) and the raw UT job log: SCA job 119578690094 terminal SUCCESS at 02:04:27Z; UT job 119578690436 terminal failure with exactly one failing case, FAIL_UT_CASES=TestPublicationSurvivesAllocatorRestart,. (2) Classified that failure against this PR from the raw record: the WARNING: DATA RACE write (pkg/lockservice/publication_test.go:118) and the previous read (pkg/lockservice/lock_table_allocator.go:1616) are upstream-tree lines — blame on the head attributes the mutating test to 04fe057bd7/upstream #29808 (merged 2026-10-21T04:19:58Z, absent from the previous merge base c7bd2e7c1d) and the handler reads to upstream history (a1220dec7, 2026-09-20; 5e965dece9e, 2026-10-04); go list -deps -test ./pkg/lockservice matches none of this PR's 22 files, so the raced test binary compiles from code identical to pristine base 0276f82fb7. (3) Ran the exact failing test locally on the untouched worktree head under the CI race configuration: -count=10, then -count=100 repetitions, both PASS with zero races (bounded attempts — the CI failure record remains the only race reproduction, consistent with a load-sensitive window). (4) Searched for an existing tracking issue (none found for TestPublicationSurvivesAllocatorRestart, PublicationSurvives, handleKeepLockTableBind or lock allocator data race; the only adjacent items are the closed 2023 #9884 for a different lockservice race and the unrelated open #26465 OOM report) and for an upstream fix to incorporate (none). Per loop policy this round therefore creates no issue, invents no marker entry, edits no code, requests no rerun (the run is at attempt 2 — its single permitted failed-jobs rerun was already used), and makes no base update; the worktree stays aligned to the pushed head c5bf41ded3. Recovery for item 6 belongs to upstream ownership of #29808's test code; once such a fix lands on main it is a verified-reason rebase for this PR.

Resolution evidence for item 6 (2026-10-22): maintainer XuPeng-SH repaired the race inside this PR with commit db727173a072a5eaf14981006bd18fcd6cf58329 (test(lockservice): replace allocator fixtures instead of mutating live epochs, head db727173a pushed at 2026-10-22 on the rebased base): every allocator-restart scenario — including TestPublicationSurvivesAllocatorRestart — now constructs a replacement allocator with its desired initial state through the new runLockServiceRestartTests fixture instead of mutating a live epoch while the allocator handler runs, which removes exactly the alloc.version++ write vs handleKeepLockTableBind read pair the race record identified; the auxiliary restart owner keeps construction, unwind and teardown inside the existing fixture owner. The UT lane of the first CI run on that head (run 39728200972, attempt 1) still behaved as recorded below for the coverage lane's separate fixture defect (item 7); the fresh run on the fixed descendant head 2b7800998c is the retry path for both lanes.

  1. RESOLVED (2026-10-22, fixed in-PR before any rerun) — Matrixone UT Coverage execution / UT Coverage on Ubuntu/x86 of run 39728200972 attempt 1 (head db727173a, job 119657029775, terminal failure 2026-10-22T06:02:26Z) failed on exactly one unit test: TestGetBindPurgesStaleBindWhenAllocatorIDChangesWithRegressedVersion at pkg/lockservice/service_test.go:3729. Unlike every earlier item this failure was in this PR's own diff: the failing test's restart behavior was introduced by maintainer commit db727173a0, and main carries no such fixture — on origin/main there is no runLockServiceRestartTests and git diff origin/main db727173a -- pkg/lockservice is exactly that commit's delta. Recorded mechanism from the raw job log: the fixture restart closes the old allocator and constructs its replacement on the same socket path while each running CN service keeps a pooled morpc backend for the connection that close just severed; getLockTableBindWithContext issues a single un-retried Send (getLockTableBindWithContext → one c.Send), and this scenario goroutine issued its get-bind before the rpc client's read loop had observed the severance, so the write failed with write unix @->/tmp/mo-lockservice-171098841/allocator.sock: write: broken pipe, surfaced at the test's require.NoError (service_test.go:3729) — a load-sensitive window any of the fixture's nine restart scenarios can lose. Per the CI rule this PR-caused failure was fixed at its root before any rerun, and run 39728200972 was anyway still pending overall (UT, SCA and BVT jobs in progress), so no rerun was requested; the new head's fresh CI run is the retry path. Fix, commit 2b7800998c (test(lockservice): drain stale allocator rpc backends on restart, test layer only, two files, +188): the restart fixture now drains every service's stale pooled allocator backend inside the dead-listener window between the old allocator's Close and the replacement's construction — a get-bind probe per service through its own client that can reach no server in that window (hence no allocator-visible effect), retried until it returns the dialer's typed moerr.ErrBackendCannotConnect verdict on the unbound socket path, which proves the stale backend has left the client pool — so the first scenario RPC after restart dials the listening replacement instead of writing into the dead connection. All nine restart call sites are covered by the fixture change without per-site edits. Regression tests added: TestRestartDrainsStaleAllocatorConnections (holds one live pooled allocator connection across a real restart; the first post-restart get-bind must succeed synchronously) and TestDrainUntilProbeDialsLegSemantics (deterministic leg semantics: severed-write and backend-closed legs retry, the dial verdict completes the drain, a probe that could reach a live allocator is surfaced as an error, persistent failures stop at the bounded deadline). Local verification on head 2b7800998c and, after the final rebase, on a1a4ce7f6f (macOS arm64, go1.27.1; identical lockservice tree): go vet ./pkg/lockservice exit 0; the focused restart family plus both drain tests -count=10 PASS (6.1 s), the three remaining restart scenarios -count=10 PASS, the owning package passes normal (60.0 s) and -race (64.8 s), and the full restart family passes -race -count=20 (17.0 s); logs retained at /tmp/pr30617-*.log on the handler host. No production lock-path change, no .github/workflows/** or mo-tester path touched, and the predecessor head's already-terminal jobs in run 39728200972 (Shared Build, CI preflight, pr-size-label, coverage eligibility, Iceberg tidy) remain SUCCESS. The fresh CI run on the final head a1a4ce7f6f provides this item's terminal proof.

Recovery performed in the 2026-10-22 coverage-window round: (1) retrieved the failed coverage job 119657029775's raw log before the run completed and identified the single failing case with its exact error (write: broken pipe on the allocator socket at service_test.go:3729, job step Fail on coverage UT failure). (2) Classified the failure against this PR's diff: the failing test's restart fixture is db727173a0 (in-PR; absent from main), and the failed write is the documented first-request behavior of the just-severed pooled backend — no upstream ownership applies, so the PR owned the fix. (3) Fixed the root cause in the shared restart fixture so every restart scenario inherits the drain, added the two regression tests above, and verified gofmt/vet, focused -count=10 repetitions, owning-package normal and race, and restart-family -race -count=20 before committing 2b7800998c and pushing it to the PR branch (db727173a0..2b7800998c). (4) Requested no rerun for run 39728200972: its UT/SCA/BVT jobs were still in progress, the failing job was caused by this PR, and the pushed head moves the retry path to the run that started automatically on 2b7800998c; this round does not await that remote run's terminal state. (5) About 40 minutes later main advanced with c0e826888b (upstream's own smaller fix of the same publication_test.go race — it keeps the in-place path but drops the live alloc.version++ while clearing bind maps), which made GitHub report this PR CONFLICTING; that actual conflict is the verified reason for the base update. The branch was rebased onto main tip 9f7fe43649: the single overlap in pkg/lockservice/publication_test.go resolved to the maintainer's restart-based test (the directions converge — upstream stopped mutating the live epoch, this fixture replaces it, and the drain leg keeps the replacement reachable), all eight commits replayed (drain commit now a1a4ce7f6f, patch identical), the restart family re-verified on the rebased tree (-count=2 PASS, /tmp/pr30617-postrebase-focus.log), the protected scope re-confirmed empty (git diff origin/main...HEAD -- .github/workflows .github/ci → no output; the PR's own 27-path delta vs main is unchanged), and the rebased head force-pushed with lease (+2b7800998c...a1a4ce7f6f). The run that had started on 2b7800998c is thereby superseded, and the fresh run on a1a4ce7f6f is evaluated on its own scan; no rerun was requested for either. This comment is updated only when a listed blocker is resolved or new evidence about it appears.

@aptend aptend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-reviewed exact head dc0ead1 against my previous review 5580442588 at 57a03a9, with the complete original change map and all historical reviews, discussion, inline replies and the resolved thread included. The increment is confined to two license headers; executable code, test oracles, dependencies and the versioned design are unchanged.

The previous blocking finding is closed by the actual files, not just the reply/thread status: I independently ran the same license-eye header check on both files (2 valid, 0 invalid, exit 0), then checked all eight newly added Go files (8 valid, 0 invalid). Formatting and full-range diff checks also pass.

The prior full implementation/design review and qualified execution evidence remain applicable: schema-scoped immutable replay admission, non-unique index/MVCC visibility, both reader paths, COW snapshots, synchronous index removal/GC, conservative fallback and bounded candidate selection. I reused the unchanged-input owning-package/focused tests, real SQL same-fixture rerun, focused race measurements plus 100 repetitions of each of the five selected concurrency roots, and focused vet evidence. Resource ownership, cancellation/release and retained-state bounds remain closed. No additional blocking implementation issue found.

I also investigated a subsequently completed failure in historical UT job 118424289848: TestCheckConstraintNamespace/repeatable_read_preserves_check_authoring exhausted its three retries for CREATE TABLE si_reused with Error 20619, catalog namespace snapshot is stale. With independently built native dependencies and the controlled wrapper, I ran the exact TestCheckConstraintNamespace root under -race -short -tags matrixone_test -vet=off -count=1 on this head and on clean merge-base c7bd2e7, serially with isolated test environments. Both completed successfully: all 18 scenarios executed, zero skips/failures; root durations 18.55s and 17.70s respectively. The CI failure was not reproduced on either revision, so this is not proof that it is pre-existing. Current full CI run 39379852775 is still in progress; this approval does not claim that pending checks passed or waive merge gates.

@XuPeng-SH

XuPeng-SH commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: dc0ead14627456d43536460709db3594ff66cd6e

Review completed. Read the assessment.

@XuPeng-SH

XuPeng-SH commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-xupeng · superseded

Commit: dc0ead14627456d43536460709db3594ff66cd6e

Review belongs to an older commit; it is not a review of the current head.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

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: dc0ead14627456d43536460709db3594ff66cd6e

Assessment: approve

Completed the 22-file review with no unresolved actionable findings. Revision 3 reasonably adds optional candidate pruning while preserving existing MVCC, cleanup and reader ownership. Schema admission, conservative fallback and bounded selection address the earlier design and performance findings; the license defects are also fixed.

Model: gpt-6-astra / xhigh

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

Validation:

  • Verified frozen HEAD, merge-base, clean source, patch equality and diff checks. The native build copy matches all 11,584 tracked files and the pinned gitlink.

  • Reviewed catalog publication, queued descriptor ownership, both committed readers, shared predicate/interval logic, duplicates, snapshots, deletion, all four GC paths, failure cleanup and public SQL test coverage.

  • The supplied exact-head CI snapshot records successful Ubuntu UT, SCA, coverage, shared build, proxy BVT and pessimistic multi-CN BVT. Verified that the increment from the previously tested revision changes only two license headers.

  • Isolation preflight and a fresh repository-owned native build/provenance verification passed. Benchmark execution used the supplied test-exec and task caches.

  • Three-sample, 100,000-row candidate benchmarks passed count assertions: selective iteration median 907,369→914 ns; excluded-duplicate-run iteration 900,693→871 ns; broad-read overhead approximately 0%, duplicate-heavy fallback overhead 4.2%. The exhaustive comparator is unchanged from merge-base.

  • Commands, source fingerprints, exits and retained logs are reconciled in /home/xupeng/.local/state/mo-bot/jobs/67d15e1d83b1855f3bdef7cc/attempt-1/review-validation.json. Final audit receipt: checks/1792488718151734426-6.json, exit 0. Coverage and accepted tradeoffs are recorded in review-map.json.

Limitations:

  • Local measurements cover candidate iteration, not end-to-end SQL latency. Active-index replay, GC and retained-memory costs remain documented author measurements; wide keys and held snapshots have substantial costs.

  • Full functional/race suites were not repeated locally. Supplied CI statuses and unchanged-input execution reports were reused; raw author/CI logs were not supplied, and skipped checks were not counted as passes.

  • The linked issue's full text was unavailable; its behavioral contract was assessed from the frozen PR, design and regression cases. Unprovable schema history intentionally retains exhaustive fallback.

@mergify mergify Bot added the queued label Oct 20, 2026
@mergify

mergify Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-20 09:34 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🚫 Left the queue — 2026-10-20 13:33 UTC · at dc0ead14627456d43536460709db3594ff66cd6e

This pull request spent 3 hours 58 minutes 39 seconds in the queue, with no time running CI.

Reason

The pull request can't be updated

GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/tpch-compare.yml without workflows permission
GitHub only lets Mergify write to .github/workflows/ with the workflows permission. An organization owner can accept Mergify's pending permissions at https://dashboard.mergify.com/orgs/matrixorigin/repositories.

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Requeued — the merge queue status continues in this comment ↓.

@mergify mergify Bot added dequeued and removed queued labels Oct 20, 2026
XuPeng-SH pushed a commit to gouhongshen/matrixone that referenced this pull request Oct 22, 2026
Adds the design document required by the repo's feature-design-review
gate for issue matrixorigin#26996 / PR matrixorigin#30617: problem and invariants, alternatives
and decision log, index completeness/ownership, schema-era state
machine, snapshot/GC lifecycle, replay CPU/memory cost model on
affected and ordinary workloads, compatibility and fallback/removal,
and the invariant-to-test validation map.
gouhongshen and others added 8 commits October 22, 2026 15:23
…l replay state

PartitionState holds committed-but-unflushed rows ordered by BlockID, RowID
and commit time, and HandleRowsInsert builds only a primary-key index from
primarySeqnum. The committed read path picks indexed iteration only for a
valid primary-key MemPKFilter, so a composite CLUSTER BY table without a
primary key can never turn the planner's merged prefix_in_range cluster
predicate into a PK filter: reads of committed unflushed rows fall back to
NewRowsIter and linearly visit every visible logtail row. The reported
EXPLAIN ANALYZE shows inputRows=100000, outputRows=2 and ReadSize=0 for a
two-row time-series range over 100,000 committed unflushed rows.

This adds a nonunique cluster-key access path for committed replay rows:

- logtailreplay: a rowClusterIndex with one entry per indexed retained
  insertion version. The hidden compound column is resolved by stable
  name and type identity with era and completeness guards, so rename,
  sequence gaps, ambiguous duplicate attributes and user columns shadowing
  the reserved prefix fail open to the general iteration. Removal is
  centralized in deleteRowIndexes at all four rows.Delete sites, Copy
  propagates the index to published snapshots, and each indexed entry
  carries a copy of the encoded key bytes (RowEntry.ClusterIndexBytes).
- rows_iter: a guarded NewClusterKeyIterWithFilters seeks the serialized
  interval, counts its interval traversal, validates visibility against
  the authoritative rows tree at the query timestamp, and keeps
  nonunique cluster iteration separate from unique primary-key
  exact-hit semantics; ClusterIndexReadyFor gates pruning per column.
- readutil: the primary-key filter's typed predicate parsing is
  extracted into a shared constructBaseSortKeyFilter core, and the new
  ConstructBaseClusterFilter and MemClusterKeyFilter build the nonunique
  cluster descriptor; NewReader attaches the cluster filter so the
  predicate reaches both committed-row datasources.
- disttae: LocalDisttaeDataSource and materializedSnapshotDataSource
  construct the guarded cluster iterator for committed reads while
  primary-key MemPKFilter and RecordExactHit one-row branches stay
  PK-only; residual SQL filtering, workspace tombstones and persisted
  tombstones are preserved.

Tests: the datasource golden fails at the parent base with 'expected 2,
actual 100000' and duplicates 'expected 9, actual 10' and passes at this
commit with rows=2, sum=39, scanned=2 (nil-filter control scans 100000).
A real-TAE integration regression ingests 100,000 genuinely produced
unflushed rows through the production logtail producer and consumer and
verifies count=2/sum=39 at scan=2, flush emptying the replay state with a
post-flush scan sum of 0, production block filtering pruning 13 real
blocks to the single block holding the matching prefix keys, and mixed
persisted-plus-replay reads returning the combined result. All synthetic
fixtures free their original vectors after the replay consumers finish
and every test pool asserts OnHeapOutstanding bytes and objects return to
zero before deletion; the BVT case passes mo-tester normal comparison on
a live service, twice on one instance with restored teardown.

Related to matrixorigin#26996
golangci-lint (make static-check-analysis) reported five findings in the
test files added by this PR:

- copyloopvar: the three redundant loop-variable copies in
  TestClusterKeyIterMatchesRowsIterRandomReplay can simply be deleted
  under the Go 1.22+ per-iteration loop semantics (go.mod pins 1.27).
- prealloc: insertRows in TestClusterKeyIterMatchesRowsIter is filled
  with exactly one row per key, so preallocate it with len(keys).
- unused: cluster_replay_test.go's local copy of clusterVecOwner.track
  is never called; the used copy in cluster_index_test.go stays.

All five fixes are behavior-preserving.
Adds the design document required by the repo's feature-design-review
gate for issue matrixorigin#26996 / PR matrixorigin#30617: problem and invariants, alternatives
and decision log, index completeness/ownership, schema-era state
machine, snapshot/GC lifecycle, replay CPU/memory cost model on
affected and ordinary workloads, compatibility and fallback/removal,
and the invariant-to-test validation map.
The exact-head SCA job (run 39360153826, job 118424289564) fails because
pkg/vm/engine/disttae/cluster_replay_admission_test.go and
pkg/tests/sqlintegration/cluster_replay_pruning_test.go carry a shortened
Apache header: the license URL sits on the preceding line and the final
limitations clause is missing, so license-eye rejects both
(checked 2, valid 0, invalid 2).

Restore the complete header used by every neighboring file. Verified with
the reviewer's exact command on both files: license-eye header check now
reports checked 2, valid 2, invalid 0, exit 0; all eight PR-added Go files
report valid 8, invalid 0. Comment-only change.

Addresses the inline license finding of aptend's REQUEST_CHANGES review at
head 57a03a9 (2026-10-20T03:31:24Z); the review's remaining findings are
already closed per that same review.
The coverage-UT lane of run 39728200972 (job 119657029775, head db72717)
failed exactly one case, TestGetBindPurgesStaleBindWhenAllocatorIDChangesWithRegressedVersion,
at the require.NoError right after the fixture's allocator restart: the first
post-restart get-bind wrote into the pooled morpc backend whose connection the
old allocator's close had just severed ("write unix @->...allocator.sock: write:
broken pipe"). getLockTableBindWithContext sends once without retry, and the
rpc client's read loop can still see the pooled connection as usable when the
scenario goroutine issues its request before the close becomes observable.
Every restart scenario can race that window on its first post-restart RPC.

Drain the stale backends inside the restart fixture instead of retrying at
each call site. Between the old allocator's close and the new allocator's
construction the socket path has no listener, so a get-bind probe through a
service's own client can only fail on the connection or dial leg and can
never reach an allocator. The drain retries until a probe returns the
dialer's moerr.ErrBackendCannotConnect verdict on the unbound path, which
proves the stale backend has left the client pool, so the first scenario RPC
after restart dials the listening replacement.

Coverage: the fixture contract is held synchronously by
TestRestartDrainsStaleAllocatorConnections, and TestDrainUntilProbeDialsLegSemantics
pins the leg semantics deterministically (severed-write and backend-closed
legs retry, the dial verdict completes the drain, a probe reaching a live
allocator is surfaced as an error, persistent failures stop at the bounded
deadline). The nine restart scenarios and both drain tests pass -count=10;
the remaining three restart scenarios pass -count=10; the owning package
passes normal (60.0s) and race (64.8s); the full restart family passes
-race -count=20. No production lock-path change.
@mergify

mergify Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-22 08:35 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-10-22 10:59 UTC · at b58d92746d619a9313fe48590eb1d491f5fe8056 · squash

This pull request spent 2 hours 23 minutes 14 seconds in the queue, including 1 hour 12 minutes 43 seconds running CI.

Required conditions to merge

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

Codex automated review

Re-reviewed exact head a1a4ce7 against previously reviewed head dc0ead1, with all PR reviews, issue comments and the single inline thread loaded. Prior disposition: my own blocking finding at 57a03a9 (two shortened Apache license headers failing required SCA, inline comment 4321180325) is fixed at dc0ead1 and the fix is retained; at the current head both files' patches are byte-identical to dc0ead1, so the blocker stays closed. The other reviewers' resolved topics (missing design artifact, revision-1 shadow-VARCHAR admission, unconditional encoding after disablement, cost-model defects) all closed before dc0ead1 by design revision 3 and the accompanying code revisions, with recorded approvals from aptend (dc0ead1), mo-bot-local (dc0ead1) and fengttt; no unresolved reviewer finding exists, and none is re-raised here. The delta dc0ead1..HEAD is a rebase onto main 9f7fe43 plus two new test-only lockservice commits and one conflict resolution in pkg/lockservice/publication_test.go: every one of the 22 non-lockservice files has a patch-id identical to the approved head, and the content drift in the three files that differ (local_disttae_datasource.go, logtail_consumer.go, pk_filter_mem.go) traces entirely to upstream commits 838cc78 (point-read bounding) and 1362ffb (first-catalog-replay reconnect) absorbed through the rebase, not authored by this PR. Deep review of the new lockservice surface: commit 3346732 replaces the live-epoch mutation that raced with handleKeepLockTableBind (the upstream CI race on TestPublicationSurvivesAllocatorRestart) by full allocator restarts through the existing fixture owner; AllocatorOption mutations apply before initServer, so no concurrent handler observes them; commit a1a4ce7 drains each service's stale pooled allocator backend in the dead-listener window between old Close and new construction, completing only on the dialer's ErrBackendCannotConnect verdict, which proves the stale backend left the pool, with a bounded 10s deadline and four pinned leg semantics; the composed publication_test.go keeps all assertions and adds deterministic writer-cleanup coverage. The exported RunLockServicesForTest signature is unchanged, so external callers (txn/client, cnservice, lockop, compile) are unaffected; remaining direct lastAllocatorID/Version reads elsewhere in service_test.go pre-date this PR on origin/main. Validation on this checkout with its own make-cgo-built native deps (darwin/arm64, go1.27.1): go build passes for all changed runtime packages; go vet ./pkg/lockservice clean; gofmt clean on changed files; full pkg/lockservice package -short PASS (73.1s); the ten-test restart family PASS -count=3; race PASS -race -count=10 on the four key restart/drain tests including both original CI failures; both new drain tests PASS -count=2; logtailreplay and readutil -short PASS; all 11 named disttae cluster-replay tests plus TestClusterByRealLogtailIntegration PASS; sql/plan ClusterBy PASS. Limitation: the embedded-instance SQL admission test in pkg/tests/sqlintegration was not run here; that file and the production code it exercises are byte-identical to the previously approved head where the recorded review ran it PASS. No blocking or non-blocking findings remain.

@XuPeng-SH

Copy link
Copy Markdown
Contributor

QA verification on main@3ad9adbb4c (post-merge), dual-CN cluster

Local CGo build, one LOG + one TN + two CNs (SQL 16001 / 16002, separate LOCAL caches, shared SHARED fileservice), so the second CN reads exclusively through its own logtail replay state.

Setup on CN1, deliberately left unflushed:

create table cb(a int, b int, c int) cluster by (a,b);
insert into cb values (1,1,10),(1,2,20),(2,1,30),(2,2,40),(3,3,50);
insert into cb select id%3, id%5, id from (with recursive s(n) as (select 1 union all select n+1 from s where n<300) select n as id from s) x;

Immediate reads (no flush, no checkpoint):

Query CN1 (owner) CN2 (replay state)
count(*) 305 305
where a=1 and b=2 → count, min(c), max(c) 21, 7, 292 21, 7, 292
where a=2 and b=3 → count 20 20

Composite CLUSTER BY predicates therefore return identical, complete row sets on the replaying CN — no scanned-everything-vs-pruned divergence, and no missing unflushed rows.

Index-sync / DML consistency across CNs afterwards:

Step CN1 CN2
create index ic on cb(c), insert (9,9,9999), delete where c=7 count=305, sum(c)=55292 count=305, sum(c)=55292
where c=9999 (index lookup) — 1
where c=7 (deleted) — 0

The 50 ERROR lines in the server log are cold-boot races only (hakeeper not ready, not enough log stores, file hk_data is not found) and stop once both CNs register.

Not covered: pruning effectiveness (rows scanned per block), behaviour under TN restart / logtail reconnect, and multi-block composite predicates spanning NULL cluster keys.

This branch was previously deployed

1 inactive deployment
ci — a2452632 Deployed Oct 22, 2026 by mergify[bot]
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/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants