Repository navigation
[v4.2.8-hotfix] fix(branch): preserve PK pruning in historical catalog reads - #32704
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? |
|
This pull request is merged. |
|
Review of Request changes: one P2 correctness issue in the newly filtered visible-state recovery path. [P2] Preserve replacement-chain metadata before applying PK object pruning. Locations: new propagation into range recovery, pruning before populating the replacement index.
Minimal metadata counterexample, with PK
A correctly stays eligible because its zonemap is unknown. B is pruned, leaving only timestamp 2 in the replacement index. Resolving A's deletion at 7 finds neither an exact nor a later successor and returns This becomes reachable in historical range reconstruction because this PR newly supplies Please retain the necessary replacement metadata while resolving lineage, and prune terminal payload candidates afterward (or explicitly distinguish a proven-disjoint successor from an absent successor). Do not turn genuinely missing successors into success. Add a regression combining Does the PR address the reported timeout? Yes, the main diagnosis and change are coherent: both historical constructors previously lost the filter; propagating it and applying checkpoint/object/block pruning can avoid reading unrelated Other boundaries checked: nil/empty filters retain the unfiltered path; unknown zonemaps fail open; rowid-sorted tombstones are not compared to user-PK object ranges; persisted appendable blocks use PK pruning without enabling their commit-TS pruning; strict commit-TS handling remains restricted to TN non-appendable objects. The new real checkpoint test checks both policies and original target timestamps; the SQL test verifies all six rows, repeat merge, conflict SKIP, insertion and deletion. These are useful additions, but do not cover the filtered replacement-chain counterexample. Validation: source/diff and test-source review, plus a small metadata/control-flow model of the counterexample; I did not execute Go/MatrixOne tests or reproduce the production workload locally. The PR author's reported test runs remain author-provided evidence. At review time, MongoDB E2E passed and Iceberg E2E was still running; the available checks do not establish a completed full engine regression run. The head was rechecked before posting. |
|
mo-bot review · Commit: Review linked issue or PR description changed before publication; a fresh contextual review is queued. |
|
mo-bot review · Commit: Review belongs to an older commit; it is not a review of the current head. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: d72ab2a1b5a1624adda860d9047e45a6a26b9e71
Assessment: approve
Historical PK pruning reuses existing filter and block-plan capabilities. The follow-up resolves the prior replacement-chain defect by retaining lineage metadata before pruning terminal payloads. No actionable findings remain.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
Validation:
-
Reviewed all seven changed files, affected callers, catalog sort-key ownership and all six discussion entries.
-
Frozen-source, diff, formatting and discussion-coverage checks passed; logs and command receipts were retained.
-
Author reports post-follow-up package, branch-history and SQL MERGE/PICK tests passing, including checkpoint/GC and replacement-chain controls.
Limitations:
-
No independent Go/SQL execution; no retained test logs were supplied in local_validation.
-
Performance measurements precede the metadata follow-up and do not establish production latency or selectivity for long/coarse keys.
|
Local focused validation for head
These were focused local checks for the changed code paths, not full-repository SCA or the full BVT suite. |
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes #32713 ## What this PR does / why we need it: Pull requests targeting `v4.2.8-hotfix` do not match the default-branch entrypoint's numeric branch filter, so `MatrixOne ALL CI` never starts. GitHub evaluates `pull_request_target` using the default branch; changing the workflow only on the hotfix branch cannot fix admission. Add the exact hotfix branch to the `main` entrypoint. This supersedes #32714. The existing PR checks and `CI Required` result then apply on the next eligible hotfix PR event. Validation: actionlint v1.7.12 passes. YAML semantic comparison verifies that the hotfix branch is the only added target and all other workflow behavior is retained. After merge, synchronize or reopen an existing hotfix PR to trigger validation; earlier events are not replayed. The merged #32704 does not receive CI retroactively. Post-merge Standalone/TKE callers are manually disabled in GitHub, so this PR makes no claim to restore those workflows. The separate Standalone checkout correction is matrixorigin/CI#477.
#32705) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes #32708. Related: #32704 (the `v4.2.8-hotfix` fix for the production FDB DATA BRANCH MERGE timeout). This is the sibling fix for `4.2-dev`, including both the original fix and its replacement-chain review follow-up. ## What this PR does / why we need it: A production MERGE updating one row in a six-row table spent 29.859 of its 29.942 seconds resolving table-creation metadata. The historical `mo_catalog.mo_tables` reader lost the frontend's exact-table PK filter and delivered 1,861,139 catalog data/tombstone versions before client cancellation. This port preserves that predicate through checkpoint and visible-state range recovery, marks the catalog's known PK sort order, and prunes disjoint object/block payloads. Object pruning requires confirmed PK-sort semantics; unknown zonemaps, cluster-by keys and rowid-sorted tombstones remain eligible. Persisted appendable blocks can use PK pruning, and tombstone blocks use their own PK sequence number. The review follow-up is included: retain TN replacement metadata until lineage is resolved, then prune terminal payloads. A disjoint replacement must not be confused with a missing successor. Genuinely missing successor metadata or matching files still return `ErrFileNotFound`. Source commits: `80708c0d8ebf4ec210596b2afa2b91e04effe51c` and `d72ab2a1b5a1624adda860d9047e45a6a26b9e71`, cherry-picked onto `4.2-dev@1d90e51` without conflicts. ### Validation Passed on this target branch (Go 1.26.4, macOS arm64, isolated local test engines/embedded cluster): ```sh go test -p 3 -count=1 -timeout 10m ./pkg/vm/engine/disttae/logtailreplay ./pkg/frontend/databranchutils ./pkg/vm/engine go test -p 3 -count=1 -timeout 10m ./pkg/frontend ./pkg/vm/engine/test -run '^(Test.*DataBranch.*|Test.*PKFilter.*|Test.*ChangesHandle.*|TestFileNotFoundFallbackToSnapshotRead|TestRealStaleReadStillReturnsError|TestPackMoDatabaseCPKey|TestDatabaseCreatedTimeToCollectLowerBound|TestGetObjectsFromCheckpoint.*)$' go test -p 3 -count=1 -timeout 7m ./pkg/tests/dml -run '^(TestDataBranchPick|TestDataBranchMerge|TestDataBranchMergeWithCheckpointCatalog)$' -v ``` Coverage includes checkpoint recovery after partition GC under both policies with original creation timestamps; real object-file reads with filtered/unfiltered replacement-chain controls; missing metadata/files; tombstone and appendable block layouts; same-type cluster keys; and SQL rename, repeated MERGE, conflict SKIP, inserts/deletes plus the existing MERGE/PICK suites. The same new regressions were proven to fail before the source fixes; target-branch regressions pass. Native sources and `go.mod` match the tested hotfix worktree, so its locally built native dependencies were copied into this independent worktree. No shared runtime was changed. Repository-wide tests and production-sized performance measurements were not repeated for this port; the original measurements and their limits remain in #32704. No schema, storage format, CLI timeout or FDB application-state recovery is changed. Approved-by: XuPeng-SH <[email protected]>
## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to #32146. ## What this PR does / why we need it: Backport the large-variable-length write memory fixes and their lifecycle dependencies to `v4.2.8-hotfix`. A 196,092-row fixture with very large JSON/text values completes its batched UPDATE on 4.2.8 but OOM-kills a 20-GiB CN during the subsequent VARCHAR-to-INT COPY ALTER. The backports bound CN spill runs and pooled writer retention while preserving buffer/object ownership through completion, cancellation, and failure. Cherry-picked with source provenance, in order: #32081, #32155, #32332, #32164, #32398, #32454, and #32065. The target branch's existing #32704 is retained. There are no manual production-code changes to the seven backports. Validation on head `cc1d6c51a156e232182030b093bbf9bfc1ae95c1`: - Fresh native build succeeds with actual-head version/commit metadata. Formatting and `git diff --check` pass. All seven commits have identical added/removed lines and paths to their source commits; only #32155 has documentation-only unchanged-context differences. - Actual-head full-data run PASS: 196,092 rows, 147,941 converted rows; PK/row count, payload byte lengths and CRC sums, final statuses, and INT type verified. All roles report `OOMKilled=false`. - CN limit and total memory+swap are both 20 GiB, 6 CPUs, GOMEMLIMIT 1 GiB, cache 2 GiB. Sampled CN RSS peak: **12.4115 GiB** (2-second sampling). Sampled cgroup usage peak: 19.7955 GiB; kernel cgroup high-water reached 20 GiB, with zero failcnt/OOM. RSS is not total container memory, so this does not imply 7.6 GiB of container headroom. - Driver start through final verification: **431.90 s (7m12s)**, including token UPDATE **221.59 s**, token COPY ALTER **200.84 s**, and remaining validation/setup. Service startup and cold-backup restore are excluded. - Native-toolchain scoped regressions pass: nine owning packages (2,302 tests/subtests); compile import/cancellation selector (153); focused race checks across mpool, rscthrottler, objectio and ioutil (93). Runs use `-count=1`, the repository CGo test wrapper, and default vet checks. No failures; task services are stopped. Full-repository CI/review is not part of this local validation, and further GitHub results are not awaited. The workload measures the MOI offset212 token-table migration, with placeholder companion tables, rather than all MOI deployment phases. Logical restore uses a shared DISK backend and changes the original physical object layout; customer data and raw logs are not included in this PR. Single-run timings are not a statistical performance benchmark. Revision `b6b9f3ba40d7bb9e598b2a8846b7ed166b4a48b7` (test-only follow-up): - Carries #32439's unordered two-observation reset assertion and #28467's 512-MiB RLIMIT target; closes the actual fixture-owned increment service; adapts first-replay setup to this release's embed API and TCP SQL transport. Production changes in the seven backports remain identical to their sources. - New local validation (Darwin/arm64, Go 1.27.1, CGo wrapper, `-count=1`): owning production packages build; all four changed test packages vet; `objectio/ioutil` full coverage and race pass; `mpool` coverage passes; `sql/compile` full normal and race pass with `TMPDIR=/private/tmp`; first-replay startup/disconnect/reconnect/prepared SQL passes normal and race. Spill-reset and fixture-ownership tests each pass `-race -count=100`. Formatting, diff whitespace, and delivery artifact checks pass. - Run 43449877707 attempt 1 failed SCA job 131969091882 (`make static-check-analysis`) on missing `embed.WithDataPath`; coverage job 131969165708 reports that build error, RLIMIT runtime allocation failure, and the fixture closure assertion. These backported test defects are addressed here; the old run is not rerun because the push triggers fresh CI. Pinned molint rebuilt for the local Go version exits zero but emits inherited analyzer diagnostics; this is not a zero-diagnostic SCA claim. - Local Parquet fanout failures also reproduce in an unmodified archive of target base `b572b5cd95a25d404cd0f0df32629b39c6fff120`; full PR compile normal/race pass with a short temporary root. No Parquet code/test is changed. Linux-only RLIMIT execution is reused from #28467's upstream coverage/race evidence; not executed on this Darwin host. Original migration and other upstream validation above retain their stated revisions/configurations; the customer-data migration was not repeated for these test changes. New CI is not awaited. Raw local logs remain outside the source tree. --------- Co-authored-by: aptend <[email protected]> Co-authored-by: XuPeng-SH <[email protected]> Co-authored-by: GreatRiver <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: 和光同尘 <[email protected]> Co-authored-by: jiangxinmeng1 <[email protected]>
#32707) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes #32708. Related: #32704 (production FDB DATA BRANCH MERGE timeout, `v4.2.8-hotfix`) and #32705 (`4.2-dev` sibling). This brings the full fix, including the replacement-chain review correction, to `main`. ## What this PR does / why we need it: The production incident merged a one-row update into a six-row table but spent 29.859 of 29.942 seconds resolving table-creation metadata. Checkpoint recovery dropped the exact-table PK predicate and delivered 1,861,139 historical catalog data/tombstone versions before cancellation. Preserve the existing predicate through checkpoint recovery and use it to prune object/block payloads. Require explicit confirmation that an object sort-key zonemap describes the requested user PK; unknown zonemaps, cluster-by keys and rowid-sorted tombstones stay eligible. Persisted appendable objects can use PK block pruning, while tombstone blocks use the tombstone PK sequence number. Commit-timestamp pruning retains its TN non-appendable restriction. Retain all temporally eligible TN replacement metadata while resolving deleted predecessors, then apply pruning to terminal payloads. This includes the review fix from #32704: a disjoint replacement cannot be removed from the lineage index and mistaken for a missing successor. Genuinely missing metadata/matching files still fail. ### Adaptation to main Source commits: `80708c0d8ebf4ec210596b2afa2b91e04effe51c` and `d72ab2a1b5a1624adda860d9047e45a6a26b9e71`, ported onto `main@1064837`. - The main range constructor already receives `pkFilter`; retain that implementation, its logical/physical column mapping, bounded-memory/spill handling, trailing-delete policy and all-version policy. - Add the PK-sort metadata guard and populate it for the catalog and all existing PICK key-materialization paths. The release branch already had these supporting fields; main did not. - Preserve main's error handling and checkpoint reader allocation while resolving cherry-pick conflicts. - Adapt the integration tests to inspect `Partition.Snapshot().GetStart()` because main no longer exposes the release branch's `GetPartitionStateStart` helper. The assertion that historical recovery is required remains in place. ### CI follow-up The full Linux race run detected concurrent callback reads/reset in the existing `issue31401CopyObserver`, between background ISCP SQL and the ALTER COPY integration test. Protect hook installation/reset and snapshot reads with a mutex; release the mutex before invoking callbacks so nested SQL remains possible. This follow-up changes only the test observer, with all existing assertions and CI checks retained. The test is not present on `4.2-dev`. The CI trace provides the before-fix race evidence; three local pre-fix plugin runs did not reproduce it. After the fix, both complete `TestIssue31401AlterCopyRebuildTransaction` and `TestIssue31401AlterCopyWaitsForLoad` scenarios pass three repetitions with `-race -tags matrixone_test`; `go vet -tags matrixone_test ./pkg/tests/issues` passes. Targeted race rechecks also pass for the other failed workspace-GC, numeric SQL, publication lifecycle, statement diagnostic capacity and disk-download tests, plus the checkpoint-catalog MERGE regression. ### Validation Passed on the original PK-pruning port using Go 1.27.1 / macOS arm64, with native libraries built in the isolated worktree via `make cgo`: ```sh go test -p 3 -count=1 -timeout 10m ./pkg/vm/engine/disttae/logtailreplay ./pkg/frontend/databranchutils ./pkg/vm/engine go test -p 3 -count=1 -timeout 10m ./pkg/frontend ./pkg/vm/engine/test -run '^(Test.*DataBranch.*|Test.*PKFilter.*|Test.*ChangesHandle.*|TestFileNotFoundFallbackToSnapshotRead|TestRealStaleReadStillReturnsError|TestPackMoDatabaseCPKey|TestDatabaseCreatedTimeToCollectLowerBound|TestGetObjectsFromCheckpoint.*)$' go test -p 3 -count=1 -timeout 7m ./pkg/tests/dml -run '^(TestDataBranchPick|TestDataBranchMerge|TestDataBranchMergeWithCheckpointCatalog)$' -v ``` The full logtailreplay package includes main's bounded range/spill/layout regressions as well as the added real-file PK and replacement-chain tests. The engine integration test verifies checkpoint and visible-state policies after partition GC and original creation timestamps. The SQL test checks all business rows for rename, repeated merge, conflict SKIP, inserts/deletes; existing MERGE/PICK suites pass too. The source PR records the before-fix failures and controlled performance comparison. Those performance samples were not rerun on main and are not a production-latency guarantee. Repository-wide tests were not run locally. No schema, storage format, CLI timeout, FDB application-state recovery or production configuration is changed. ### Follow-up: prefer snapshot reads for table creation timestamps The QA follow-up showed that the expensive work could be avoided for an original catalog row. Prefer a compound-primary-key snapshot probe and accept its creation timestamp only when the table ID, original catalog version, and timestamp range all match. Keep historical CollectChanges replay and the ID-based recovery for cases where the probe cannot prove the creation timestamp. Reuse the proven boundary for the same physical generation so an ALTER that rewrites a catalog row cannot hide an earlier conflicting write. The historical path also reuses bounded checkpoint metadata within each statement, avoids repeat file prefetches, overlaps catalog metadata reads, coalesces overlapping persisted-block reads, and uses less allocation when collapsing per-key versions. On main, the probe uses each operand's physical owner account. Coalescing applies to unbounded reads, retains each block's special-column layout, and leaves the bounded window, spill, and trailing-delete handling in place. On QA, the six-row single-update MERGE took 62.946 s on the existing CN and 0.834 s on one isolated CN with these optimizations, using the same older database. Each CN ran once. The baseline spent 56.10 s on four catalog replays. The optimized run resolved both timestamps via snapshot reads in 4.08 ms and 0.12 ms and verified all six output rows. This benchmark used the QA hotfix-based image. The 4.2-dev counterpart is #32925. Local validation for this follow-up on Go 1.27.1 / macOS arm64: - Full tests for objectio, objectio/ioutil, tae/logtail, disttae/logtailreplay, and vm/engine, including main's bounded replay and spill tests. - Targeted frontend, vm/engine/test, and tests/dml regressions for DATA BRANCH, checkpoint range and metadata reuse, PK filtering, stale-read recovery, and branch operand identity. - The checkpoint-catalog SQL regression checks rename, repeated merge, conflict preservation after a catalog rewrite, inserts, and deletes. Repository-wide CI runs on this PR. Approved-by: XuPeng-SH <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #32708.
Sibling ports: #32705 (
4.2-dev) and #32707 (main).What this PR does / why we need it:
A production merge of a six-row table, with one customer-name update, spent 29.859 seconds of its 29.942-second execution resolving a table's creation commit timestamp. That lookup emitted 1,861,139 historical
mo_catalog.mo_tablesdata/tombstone versions. The business table's size was not the source of that scan.The frontend already builds a composite-PK predicate for the exact account/database/table. After catalog history leaves the CN partition-state window, checkpoint replay and range-based visible-state reconstruction lost that predicate. Consequently, resolving the branch ancestor read unrelated catalog history before doing the merge.
This change:
mo_tablescomposite key as its object sort key. The shared object-pruning helper only compares a sort-key zonemap with a PK predicate when that relationship is explicitly known. Unknown zonemaps, cluster-by keys and rowid-sorted tombstones remain eligible for reading.No storage format, schema, merge conflict policy, transaction/rollback policy, or CLI timeout is changed. Callers without a PK predicate retain the unfiltered behavior. Recovery of an application-level change record already stuck in
committingis outside this engine fix.Reproduction and correctness evidence
10d204b8763f19b2b37ba2147d1d4c1a7828d6d4, substituted using Go's overlay), the test fails under both checkpoint replay and visible-state policies because it emits an unrelated table ID. The same test passes with this change and verifies the exact target table ID and original creation commit timestamp for every emitted version. Its unfiltered control still sees the unrelated history.SKIP, insertion and deletion.Validation
All commands were run from the worktree root with its locally built CGO dependencies (
make cgo),GOWORK=off, on macOS arm64 / Go 1.26.4:The baseline reproduction intentionally fails; the corrected implementation and the listed regression suites pass. This establishes the lost-filter fix and the tested data-correctness boundaries. Repository-wide tests and a production-sized historical-catalog benchmark were not run locally; CI and deployment verification are still required. Production data/configuration were not modified.
Controlled local performance comparison
Compared the base production source (
10d204b8763f19b2b37ba2147d1d4c1a7828d6d4) and this PR (80708c0d8ebf4ec210596b2afa2b91e04effe51c) on the same macOS arm64 host (10 logical CPUs, 32 GiB RAM), Go 1.26.4,GOMAXPROCS=6, and the same isolated 1 LOG / 1 TN / 3 CN test-cluster configuration. Both binaries use the same temporary Go-overlay harness; the base overlay substitutes the two changed production Go files with their exact base versions. Production was not used for these measurements.For each run, the harness creates the given number of unrelated tables in
sales, flushes catalog data in groups of 256, drops half the unrelated tables, and creates seven independent six-row source/destination branch pairs. Each source has exactly one changed row. After checkpointing and truncating only the CNmo_tablespartition history, the harness asserts that checkpoint recovery is required, then measures each actual MERGE and checks all six destination rows. Preparation, validation queries and cleanup are excluded from the MERGE timer. Runs are serial; the larger fixture reverses the base/fixed order. The table reports medians of rounds 1–6, with the first request retained separately. Caches were not forcibly cleared.Catalog lookup duration is the sum of the four
DataBranch-TableCTS-CollectChanges-Donecalls within each MERGE. Returned catalog versions count data plus tombstone rows delivered by those calls; this is not physical I/O bytes. All measured MERGEs passed the same complete-row correctness check.The long-database-name control (
branch_catalog_performance, 2,048 unrelated tables) did not show a speedup: MERGE medians were 44.16 → 47.15 ms; catalog lookup medians were 21.18 → 23.29 ms. The fixture's full composite key is 46 bytes; existing varlen zonemaps keep only 30 bytes per boundary. An executable key-range probe confirms that unrelated and target keys overlap in this control, while the 25-bytesaleskey remains distinguishable. Preserving the PK filter cannot guarantee a selective zonemap in every naming/data layout. All control runs still returned the correct business rows.The base 8,192-table run completed all seven measured MERGEs and all complete-row validations, but its later single-transaction
DROP DATABASE salescleanup failed withrow level lock is too large that need upgrade to table level lock(20707). That whole test process exited 1; it is not reported as a passing test. The timing/result markers precede this cleanup failure. The other five test processes passed. This baseline-only post-measurement failure is preserved in the report and raw logs; it was not retried or hidden.These are local workload comparisons, not a production-latency SLA. They do not justify comparing the incident's approximately 30 seconds directly with the local approximately 30 milliseconds. Production has a larger history, object-storage/network costs and concurrent load. The harness, all samples and exact commands are retained in the local investigation artifacts; no timing thresholds or CI gates were added.
Review follow-up: preserve replacement-chain metadata
Addressed the P2 finding in the review. A historical predecessor may have an unknown or broad PK zonemap even when its terminal TN replacement is disjoint from the requested PK. Removing that replacement from the create-time index makes a complete chain look like missing metadata.
The range-recovery path now retains all temporally eligible TN replacement metadata, follows deleted intermediate objects, and applies PK pruning only to terminal payload candidates (including orphan live objects). A genuinely missing successor or a missing matching object file still fails with
ErrFileNotFound.The new
TestHistoricalChangesPKFilterReplacementChainexercises the public range-recovery constructor and real object-file reads together. Four valid unknown/coarse appendable/CN predecessor cases reproduce the error on80708c0d8ebf4ec210596b2afa2b91e04effe51conly with the filter enabled; they pass after the follow-up fix and preserve the target row's original commit timestamp. Controls verify that missing successor metadata, a missing matching successor file, and a disjoint intermediate without its next successor remain errors. Every scenario also runs without the filter.Revalidated the full directly affected
logtailreplay,databranchutilsand engine packages; the frontend/engine branch-history selection; and the SQL MERGE/PICK suites including the checkpoint-catalog merge test. The previously reported larger performance comparisons remain pinned to80708c0d8ebf4ec210596b2afa2b91e04effe51c; they were not rerun for this follow-up. Checkpoint object pruning is unchanged.