Repository navigation
[4.2-dev] Backport #26616 table_changes to 4.2-dev - #32849
jiangxinmeng1 wants to merge 41 commits into
Conversation
- [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [x] Feature - [ ] Test and CI - [ ] Code Refactoring issue matrixorigin#26615 Agent/catalog incremental discovery --------- Co-authored-by: gouhongshen <[email protected]> Co-authored-by: XuPeng-SH <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit ed4a810)
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? |
|
Tick the box to add this pull request to the merge queue (same as
|
…6-4.2-dev # Conflicts: # pkg/vm/engine/change_handle_pk_filter.go # pkg/vm/engine/disttae/logtailreplay/change_handle.go
|
@XuPeng-SH The overlapping-chunk spill finding in your review of 8126a92 is addressed by f1bafa9: bounded windows process and release each chunk before loading the next one. TestChunkedColumnRoundTripAndRangedRead checks an overlapping two-chunk window with zero spill reservations. The earlier spill cleanup and duplicate-read findings also have focused regression tests. Please re-review the current head when convenient. I have merged the latest 4.2-dev and am working through the separate changed-line coverage failure. |
…6-4.2-dev # Conflicts: # pkg/objectio/ioutil/sinker.go
…6-4.2-dev # Conflicts: # pkg/vm/engine/disttae/txn_table.go
|
mo-bot review · Commit: PR closed or head changed |
|
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: a2e778bece54b7d7466862fecf0f67b08c0b3a45
Assessment: request_changes
Bounded table_changes replay can return incorrect change streams after partition-state GC or object compaction, and it requires spill admission even for a single in-memory row. The backport also adds an optional persisted-format writer and mixed-version gate that conflict with the pinned 4.2 maintenance policy. The earlier spill-cleanup, window-sizing, duplicate-read and overlapping-chunk concerns are resolved; the new replay counterexamples invalidate the earlier no-blocker assessment. Reusing the existing replay and spill-budget owners is appropriate, but their bounded integration needs these corrections.
Model: gpt-6.1-terra / max
Session: 01a2319b-6eff-73c0-b59b-ebce3800e538 · slot 2 · generation 16
-
P1
pkg/vm/engine/disttae/change_handle.go:445: A nonempty lower watermark predates the live partition state's retained history, for example after a consumer has been stopped longer than the one-hour partition-state retention period.
Impact: The query can succeed while omitting deletes, so a consumer that advances its watermark retains stale downstream rows.
Evidence: The new bounded branch always builds from the end snapshot, bypassing the existing checkpoint-splitting path. The range constructor logs and proceeds when stateStart exceeds start, although partition GC removes retired tombstone entries. The retained retention-valid-test.log probe returned a delete at timestamp 100 for (50,120], then returned no rows and no error for (50,200] after GC at 160. Reconstruct the missing nonempty range through a complete supported history source, or return a stale-range error when completeness cannot be established; handle the empty initial watermark separately. -
P2
pkg/vm/engine/disttae/change_handle.go:641: A bounded range includes an object retired by compaction and an unrelated TN object created later in the same table.
Impact: The change stream can emit a delete for a key that did not exist at the lower watermark, causing consumers to process a spurious change event.
Evidence: The newly normal bounded SQL path invokes the existing delete-chain resolver, which treats the earliest later TN creation timestamp as a successor without establishing lineage. In fuzzy-test.log, an insert at 100 followed by a delete at 120 correctly cancels while its object remains visible; after that object is retired at 150, an unrelated object created at 160 is selected as its successor and the same range incorrectly emits the delete. The timestamp heuristic predates this PR, but this change makes it the ordinary bounded table_changes path. Read a complete historical source or require verified successor lineage and fail or recover when it is unavailable. -
P2
pkg/vm/engine/disttae/logtailreplay/change_handle.go:3434: Any nonempty bounded range is processed while spill-file admission is unavailable, even when all its rows fit within the configured in-memory limit.
Impact: Small table_changes polls fail under spill quota pressure and otherwise incur spill-file I/O and reservations unnecessarily.
Evidence: Every enabled range enters prepareRangeNetEffectSpill, and spillBaseHandleByPrimaryKey opens a file for its first nonempty batch. The focused probe observed a one-row range fail on its first denied file reservation despite a 64 MiB limit; the admitted control opened two spill files. ChangeRangeLimit documents spill for excess rows. Compute net effects within the existing bound for ranges that fit, transitioning to the existing spill mechanism when needed. -
P2
pkg/sql/colexec/s3util.go:282: The 4.2 backport introduces an opt-in chunked persisted-column writer controlled by a new per-feature RPC-version threshold intended for mixed-version upgrades.
Impact: This adds another on-disk writer format and rollout mechanism to 4.2 without a default deployment benefit: the branch advertises protocol 12, below the new threshold of 29. The live RPC value is also not a durable format-capability record.
Evidence: The pinned .agents/skills/mo-dev/references/upgrade-compatibility.md 4.2 maintenance policy defers optional format evolution to main and disallows extending protocol gates for unsupported mixed-version operation. The existing legacy-column window path already supports bounded replay, including spill for oversized columns. Defer the optional writer and its PR-owned gate, while retaining any reader required by supported released artifacts, unless an applicable 4.2 maintenance need justifies the format change.
Validation:
-
The private /tmp and loopback preflight passed. Native libraries were reused only after matching 170 source inputs and six output hashes; an initially mismatched artifact was rejected.
-
Focused Go tests passed for ObjectIO, replay, table functions, planner and frontend authorization. The one-row spill-admission probe reproduced the reported behavior. See focused-tests.log and receipt checks/1796155497387757129-3.json.
-
The retained GC and unrelated-successor probes passed by asserting the observed incorrect results. See retention-valid-test.log and fuzzy-test.log, with receipts checks/1796156354065112028-3.json and checks/1796155953581275456-3.json.
-
Selected legacy and chunked ObjectIO, publication, writer-gate and disttae routing tests passed. See shared-owners-tests.log and receipt checks/1796156009583508781-3.json.
-
The frozen CI snapshot reports successful build, unit, proxy Compose and pessimistic multi-CN jobs. All 14 discussion keys are accounted for in discussion-assessment.json.
Limitations:
-
The counterexamples exercise the production replay reader with constructed object state; they were not reproduced through a running SQL cluster. The frozen CI summary does not identify whether the new distributed SQL case was selected.
-
No verified v4.2.9 release artifact or applicable newer hotfix was available in the supplied checkout, and no release-artifact upgrade or backup/restore test was run. The older v4.2.8 tag was not treated as the latest release.
An in-place ALTER replaces the mo_tables row under the same key. DATA BRANCH needs the original commit to include pre-ALTER writes in its diff. Keep the history policy when a partition handle opens later ranges and reject full-history requests on the bounded net-effect reader. Keep storage error codes on an incomplete table_changes read and tell clients how to retry the fixed window. Check structured TN flush responses in BVT so serialization whitespace cannot fail a successful flush.
Drop the backport-specific SIMD workaround superseded by matrixorigin#33001. Use the release Makefile to select the toolchain in go.mod and generate matching service and unit test coverage blocks.
Use the same Unicode case rules as catalog lookup. Otherwise a newer toolchain maps previously distinct primary-key columns to one name during delete replay. Reuse the normalized name for both column and key lookups.
|
mo-bot review · Commit: PR changed before dispatch |
Summary
Backport #26616 to
4.2-devfor #26615. Consumers can usechange_watermark()to choose a transaction boundary andtable_changes()to read the net changes for each primary key in(after, until]. An emptyafterbootstraps the consumer with rows visible atuntil.Replay and resource use on 4.2
Validation
table_changesstatements and all 141 DATA BRANCH statements passed, including an insert and a delete flushed separately and read at three different boundaries.mo-service. Eleven affected packages passed their full unit tests. ObjectIO, logtail replay and disttae also passed with the race detector. Incremental static analysis reported zero issues in the checked packages.(cherry picked from commit
ed4a810a539d8b7feae95711d37e7d7d9449d89f)