Repository navigation
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review — no material blocker found on 01cbb5588996678ae721ef1d988fb7b2070e23a6.
This is a GitHub COMMENT, because the authenticated reviewer account is also the PR author. It records the review conclusion; it is not a formal independent APPROVE.
Reviewed all eight files and every changed hunk against merge-base 23d8f61252f3017dff218b530817a240206fd762; freshly fetched main was 2726fb419b3afa1db2686ae1b2aaca563d1ae214, whose additional changes do not change this diff. No subagents, source changes, or weakened assertions.
Design and responsibility ownership
The repair addresses the actual invariant from #29710: retained workspace writes and the restored transfer frontier must describe the same completed generation. IncrStatementID now records the actual transfer frontier/debt at the same boundary as the existing write offset. RollbackLastStatement restores the discarded statement's own entry, rather than the preceding statement's pre-advance snapshot. Therefore a successful earlier persisted replacement is retained without making its source interval eligible for duplicate replay. Strict RowID cardinality checks remain unchanged.
This replaces the existing timestamp history; it does not add a second history, workspace copy, transaction owner, or retry state machine. The old field is removed from runtime state, diagnostics and transaction cleanup. The history remains bounded by transaction statement lifetime and is truncated on statement rollback and released on transaction destruction. This is an ordinary corrective change, exempt from the feature/major-refactor design-document gate, while still requiring R3 lifecycle/transaction reasoning.
The in-memory/persisted distinction is necessary. In-memory transfer rewrites retained RowIDs in place, whereas persisted replacements are appended after the statement offset and removed when that statement is rolled back. Including intermediate deleted objects only for the in-memory transfer projection handles A→B, rollback, B→C without teaching the unchanged PK-check/persisted-source consumers to replay intermediate generations. Both projections share the existing object-window collector; no parallel traversal implementation was introduced. (begin,end], final target survival and zero-width semantics are retained.
Adversarial and unhappy-path checks
| Boundary challenged | Control and terminal result |
|---|---|
| Rollback after a previously successful transfer | Compared with no rollback and rollback of the transferring statement; new real-engine matrix covers memory, persisted and mixed tombstones, repeated following-statement rollback, another merge, and a fresh transaction's committed read. All nine cells pass in current-head CI. |
| Snapshot remains ahead after rollback | Restored pending debt is preserved or re-established from the operator snapshot. Commit checks debt before its age-based skip; ordinary next-statement execution advances/transfers. Existing immediate-COMMIT cases and partial-I/O/cancel recovery pass in current-head CI. |
| Partial progress survives in memory | The retry source set admits deleted intermediate objects; persisted recovery still uses the original snapshot-visible source. I also traced workspace dumping: non-commit dumping does not spill DELETE batches, and commit's delete dump follows transfer, so the presumed memory-to-persisted escape before recovery is not a reachable counterexample in this path. |
| Object-window changes affect other callers | txnTable PK checks still call the default projection; persisted flow still uses CollectObjectsBetween. The boundary test checks both old projections before adding the intermediate-delete expectation for the new one. |
| No demand versus matching transfer | Target stats/prefetch are now inside the first actual RowID match. The no-demand test makes a prefetch lookup fail synchronously and separately uses a nil partition state to detect target lookup. Its positive control observes ten distinct real pipeline prefetch callbacks and injects metadata-read failure. This is stronger than racing an asynchronous zero-call counter. |
| Batch flush and failure cleanup | Vector Reset preserves the non-nil allocation guard, so later transfer batches reuse the target list rather than materializing/prefetching it again. Existing byte-boundary/tail coverage checks actual PK→RowID pairing. Scratch vectors/bitmap/readers retain their existing deferred cleanup; the new test checks mpool balance and unchanged input RowID after error. |
Q1: statement state stays workspace-owned; transfer scratch stays invocation-owned; optional prefetch work stays pipeline-owned and cannot rewrite workspace state. Q2: there is no new mutex, channel or wait loop. The added rollback snapshot read uses the existing operator RLock, with the same workspace-to-operator order already used by statement entry and the existing Txn() read. Retry quiesces the prior SQL generation before rollback; transfer reads receive the operation context; prefetch uses the existing nonblocking queue. The new fixture drains/stops its pipeline before restoring the previous runtime. Q3: the history is transaction-scoped, object maps are invocation/window-scoped, and row/byte batch limits and prefetch queue admission are retained. No new accumulating background state or retry loop was found.
Performance and engineering quality
The no-demand branch removes replacement-object lookup/materialization and optional whole-file prefetch. Matching transfers retain the same target set and threshold; initialization remains once per invocation, with no second workspace pass inside transferTombstones. The correctness repair does have a cost: the memory projection retains intermediate deleted names, and windows previously containing only intermediate changes can now cause a workspace scan. That work is relevant to retained rewritten RowIDs, and the demand gate avoids unnecessary target I/O when none match. It would be inaccurate to claim zero overhead or a proven overall TPCC TPS/P99 improvement.
The historical bookkeeping microbenchmark and the author's ten-to-zero prefetch observation are narrow measurements, not physical S3-byte or end-to-end throughput evidence. Full TPCC replay and identification of the first introducing commit remain unverified. The bounded fix can be assessed without claiming either; this review makes no introducing-PR attribution.
Tests add distinct behavioral cells at appropriate layers: a small state-restoration table, an extension of the existing object-window test, a controlled prefetch/error fixture, and the existing real engine harness for durable merge/rollback behavior. The new nine-cell engine matrix takes 8.89 s under the current CI race run. Reusing that fixture is justified by real merge/storage visibility; adding another embedded SQL cluster or a full TPCC workload to these UTs would not improve the focused oracle. The current SQL rollback BVTs provide the public statement/commit controls; deterministic merge interleavings are checked in the real engine tests.
Separate cumulative accounting: production 4 files, +58/-37; tests 4 files, +214/-0; documentation 0; generated files 0. The test increment was reviewed as code, not discounted because it is testing.
Evidence inspected and reused
- Current-head CI run 37871189942: successful, exact SHA verified. UT job uses Go 1.27.1 Linux/amd64, repository CGo setup,
UT_SHARD=all, fresh test cache and race mode. I checked the complete-package routing and its terminalUNIT TESTING SUCCEEDEDresult. - Named current-head results:
TestRCSnapshotRollbackAcrossMergeand all nine subtests PASS;TestTransferPartialIORecoveryfailure/cancel PASS; all sevenTest_RCSnapshotAdvanceHarnessStatementRollbackcells, including immediate commit, PASS;TestRCMemoryTransferWidePKBoundaryPASS. These are actual executed controls, not an inference from the green rollup alone. - Compose/proxy BVT job:
pessimistic_transaction/rollback_stmt.sql,rollback_stmt2.sql,rollback_stmt3.sqlreport 36/36, 36/36, 35/35, with zero failures, ignored or abnormal cases. - Current coverage artifacts show the changed production blocks executed; coverage is supporting evidence, not the correctness oracle. Exact-head local normal/race and 100-repeat fixture evidence is reported in the PR body; it was not independently rerun in this review. PR-range
git diff --checkindependently passes.
There were no prior human reviews or inline threads at capture: the sole issue comment is Qodo's paused-review notice, not a code finding. Thus there is no outstanding historical review finding to mark resolved.
Conclusion: the fix is cohesive, uses the existing owners, preserves the old consumers' contracts, and has credible regression/negative-path evidence. No verified correctness, cleanup, compatibility or unjustified-complexity blocker remains from this review. No claim of a full TPCC performance pass or formal independent GitHub approval is made.
…ck (#30580) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to #29710. Backports #29754 (`aee2a0b3764781a8ca908618548dfef75e336263`) to `4.2-dev`. ## What this PR does / why we need it: A later statement rollback could rewind transfer progress past replacements retained from a successful statement. Replaying that interval duplicates persisted tombstone replacements; another merge then fails the strict transfer cardinality check (`expect 20, got 10`). Conversely, rolling back the transferring statement must retain recovery debt so immediate COMMIT cannot skip transfer. - Save the existing workspace transfer frontier and pending debt alongside each statement's write offset; restore both on rollback without rewinding the operator snapshot. - Include intermediate merged objects when recovering in-memory RowIDs, which earlier transfers update in place. Preserve the default snapshot and persisted-source projections. - Prepare targets and prefetch only after finding a matching workspace delete. - Retain `4.2-dev`'s `ApplyFlush` tracing, lookup path, batching, and strict cardinality guard. No format, configuration, or native changes. This is an independent backport. The lineage snapshot caller correction in #30576/#29539 remains separate. Validation (Go 1.26.4, Darwin arm64, CPU CGo): - Full `disttae` and `logtailreplay` packages pass normally and with race. - All seven snapshot-harness consumer tests pass normally and with race: memory/persisted/mixed × three rollback boundaries across real TN flush and a second merge; immediate COMMIT; partial persisted I/O failure and cancellation after memory transfer; durable fresh-transaction assertions. - Prefetch admission checks no-demand lookup/prefetch avoidance, ten distinct demanded prefetch completions, unchanged RowID on metadata failure, and scratch cleanup. - Counterexample: reverting only the intermediate-memory-source projection makes the new real-engine transferring-statement rollback test fail with ten surviving rows; the candidate passes. The persisted `expect 20, got 10` baseline witness was established separately before this backport. - External MySQL probe against the candidate embedded cluster passes retained DELETE + later statement error + continuation/COMMIT, error + immediate COMMIT, and full rollback with fresh-connection results. This checks public rollback behavior, not deterministic public SQL reproduction of the forced merge interval. - Separate bounded race repetitions pass: admission 100, statement rollback 4, rollback across merge 3, partial I/O recovery 15. Counts use a 30-second per-test budget and measured one-run race durations. - `go vet`, configured molint, configured golangci-lint against the exact branch base, formatting, and diff integrity pass. Reproduce the repository regression checks: ```sh .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/vm/engine/disttae ./pkg/vm/engine/disttae/logtailreplay .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s -run '^(Test_RCSnapshotAdvancePreservesUncommittedDeletes|Test_RCSnapshotAdvanceHarness(Rollback|Commit|SubsequentStatement|StatementRollback)|TestRCSnapshotRollbackAcrossMerge|TestTransferPartialIORecovery)$' ./pkg/vm/engine/test ``` Both selections also pass with `-race -count=1 -timeout=600s`. No workload throughput or physical I/O improvement is claimed.
…nce (#30602) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to #30541. Production fixes are already present on main through #29539 and #29754; the release-branch correction is #30576. ## What this PR does / why we need it: Add the missing deterministic catalog regression for COPY ALTER's DROP/rename window. Existing main tests cover transferred data deletes and replacement keys, but do not check the same-name catalog replacement and the next real `txnDatabase.Delete` singleton guard. The test commits an original table, creates its transaction-local replacement, drops and renames through the real engine APIs, synchronously flushes `mo_catalog.mo_tables` on TN, and advances through the shared lineage helper. It then requires exactly the replacement table ID and successfully executes the next real Delete. There is no statement boundary between flush and verification: a normal boundary could repair the stale tombstone and hide the original defect. Setup reuses EnginePack with long checkpoint scanning, one PK column, two table identities, and no user data rows. Pack, setup/RC transactions and query results register cleanup immediately. No production hook, state, guard relaxation or runtime change is introduced. Validation on Go 1.27.1 / Darwin arm64 CPU, with matching native provenance: - New focused regression passes normally and with race; the normal test body takes about 0.75 s. - Full `./pkg/vm/engine/test` passes normally (162.995 s) and with race (226.079 s): 167 top-level passes in each mode; two existing tests remain skipped and are not claimed as executed. - An external Go overlay changes only the shared helper back to raw operator advancement. Its witness confirms both original and replacement IDs, then catches the real `delete table failed: query failed` panic from `db.Delete`. The mutation is not delivered. - The exact new test also passes 37 repetitions under race in one process (31.277 s total); count selected from a 30-second budget and a measured 0.79 s single-test race duration. - After main advanced to `d0e7f9a552f`, the exact regression also passes normally and with race using an external overlay of the complete upstream delta. Full-package results above apply to the frozen `8732827` base; the overlay check is focused compatibility evidence. - `go vet`, repository-pinned molint and configured incremental golangci-lint against `873282742714436bff407dfcdbbe879147162bd3` pass; formatting and diff integrity pass. Commands: ```sh .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=900s ./pkg/vm/engine/test .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=1200s ./pkg/vm/engine/test ``` This is regression coverage for the existing main fix, not a new production fix. It does not claim deterministic public SQL scheduling of a mid-ALTER flush, execution of the original Matrixflow upgrade workload, crash recovery, or a workload performance improvement. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
Closes #29710
What this PR does / why we need it:
RC statement rollback retained a previous successful persisted tombstone replacement while rewinding transfer progress to an older statement snapshot. Retrying replayed that interval and appended a duplicate replacement, eventually failing
expect 2, got 1on another object rewrite.Replace the snapshot history with actual statement-entry transfer frontier/pending state, paired with the existing write offsets. Restore the discarded statement's own entry state and outstanding transfer debt when the operator snapshot remains ahead, including immediate COMMIT recovery.
Transferred in-memory RowIDs are rewritten in place and can survive rollback. Include intermediate deleted objects as memory-transfer sources when they are merged again before retry. Share the object-window collector while preserving default PK-check and persisted-tombstone filters and strict cardinality checks.
Prepare replacement-object stats and prefetch only after the workspace scan finds a matching transfer intent. The existing vector-allocation guard initializes targets once across bounded batch flushes. Unrelated intermediate merges no longer cause target lookup or whole-file prefetch when no RowID needs transfer. No extra workspace scan or state machine.
Validation
Validated revision
01cbb5588996. Current complete PR delta against merge base23d8f61252, Go 1.27.1 with repository CGo configuration:disttaeUT: passed.disttaeUT with-race: passed.disttae,logtailreplay, real engine tests): passed, covering memory/persisted/mixed rollback, snapshot advances, immediate COMMIT, partial I/O/cancellation, lineage, wide-PK and object-window boundaries.-race.go vet, configured molint and configured golangci-lint v2.14.0 passed; lint reports the delta against the merge base. Gofmt and diff checks passed.gpt-6.1-sol / xhigh(PASS; no unresolved material blockers).Historical evidence for the unchanged original rollback contract: pre-fix real CN/TN two-row persisted reproduction failed 3/3 while controls passed 3/3; a memory merge/rollback counterexample exposed a reappearing deleted row. Full normal UT on all three packages and isolated
rollback_stmt.sqlBVT twice with verified teardown passed before the main merge. Current-code race consumer validation above rechecks the affected transfer paths. No additional BVT is needed for internal optional prefetch admission.Performance and scope
A no-demand white-box case that previously issued ten
PrefetchFilerequests now issues none and skips replacement-object materialization. Matching transfers retain their existing target set, prefetch threshold and bounded batching. This verifies request elimination, not physical S3 bytes or overall throughput.One existing per-statement history is replaced; no additional stack, lock or workspace copy. The earlier 64-entry history microbenchmark reduced bookkeeping from 7,504 B/7 allocations to 1,744 B/6 allocations; this is historical local measurement, not an end-to-end claim. Default PK checks and persisted object source filtering retain their original paths.
Tests use real engine storage/merge for durable behavior and a minimal controlled FileService boundary for prefetch/error behavior. Full TPCC workload and the first introducing commit remain unverified. No wire, catalog, persisted-format, configuration or topology changes. Remote CI is pending after the update and has not been awaited.