Repository navigation
fix(disttae): prune unflushed composite CLUSTER BY reads in CN logtail replay state - #30617
Conversation
|
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
Resolution evidence for this PR (2026-10-22): repo maintainer XuPeng-SH force-pushed the rebased head
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 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, Resolution evidence for item 6 (2026-10-22): maintainer XuPeng-SH repaired the race inside this PR with commit
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 ( |
aptend
left a comment
There was a problem hiding this comment.
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.
|
mo-bot review · Commit: Review completed. Read the assessment. |
|
mo-bot review · Commit: Review belongs to an older commit; it is not a review of the current head. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
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.
Merge Queue Status
This pull request spent 3 hours 58 minutes 39 seconds in the queue, with no time running CI. ReasonThe pull request can't be updated
HintYou should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again. Requeued — the merge queue status continues in this comment ↓. |
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.
…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.
Merge Queue Status
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
left a comment
There was a problem hiding this comment.
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.
QA verification on
|
| 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.
What type of PR is this?
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-22mainadvance (c0e826888b, upstream's own smaller fix to the samepublication_test.gotest) 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'sErrBackendCannotConnectverdict, 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 onbcb956d421:Design: versioned revision 3 (document content is unchanged by this rebase and test correction).
gpt-6.1-sol / xhighdesign approval, session01a156e9-7d52-7913-9900-e06502c7c49e: rev2 exact reviewed hashfa3ac0adde617b2e1b1801127845f97d52bc4743e49337b454cabdf999e7a503; bounded-selection rev3 hash339e976b9e8ace0071cda93f284e5573724d83ab292d0043e8d0a1e87251df19. Status/implementation-cost clarifications are recorded separately in the document. Final overall review: GO, no unresolved material blockers,gpt-6.1-sol / xhigh, session01a15720-633a-7bd1-b65d-0353ecea797e, exact commit57a03a91bfcac09da7a41683ac37d0a612aa04a2.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 consumerTestCheckLockTableBindsChangedWithStaleLocalCachepasses normal and race.Allocator-restart drain correction (commit
a1a4ce7f6f, newest head;2b7800998cbefore 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=2on the rebased tree.Fixture correction design and final review use
gpt-6.1-sol / xhigh; design session01a161bb-1865-70b3-bb43-5a85e17dcf6a, review session01a161c9-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 commitdb727173a072a5eaf14981006bd18fcd6cf58329.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
57a03a91bfagainst basec7bd2e7c1d9ca53daf80d640b3b307902d54161c: 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: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.