Skip to content

[4.2-dev] fix(disttae): preserve exact PK reads across transferred deletes - #32692

Merged
mergify[bot] merged 3 commits into
matrixorigin:4.2-devfrom
LeftHandCold:backport/4.2-exact-pk-visible-history-32660
Nov 14, 2026
Merged

mergify[bot] merged 3 commits into
matrixorigin:4.2-devfrom
LeftHandCold:backport/4.2-exact-pk-visible-history-32660

Conversation

@LeftHandCold

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Backport of #32668 to 4.2-dev, addressing #32660 on this release branch.

What this PR does / why we need it:

Cherry-pick 50bb07caae467c08b951154757933323e5c607fa with -x, onto
4.2-dev@2397892f71a937903f72dab41bd2199479102eef. There were no conflicts
and no branch-specific source or test adaptations.

logtailreplay.Exact must not infer that a unique PK is absent after inspecting
only three historical candidates. Multiple transferred deletes can precede the
live insertion and consume that budget. The old implementation returns an empty
SQL result without an error, while prefix/full scans find the same row.

The patch changes only iterator-local termination:

  • Check the key boundary before skipping entries from the opposite stream.
  • Skip all preceding same-key transferred deletes, with no arbitrary count cap.
  • For unique-PK data iteration, validate only the newest insertion at/before the
    snapshot using the existing RowID/version visibility logic, then finish.
  • Keep delete iteration eligible to visit every matching physical RowID.

No TN, Flush scheduler, lock protocol, persistence format, allocator/FATAL, shared
state or retry changes. No main-only cluster-key/range changes are included.

Branch-specific validation

Validation runs on host 50 in an isolated worktree with a fresh 4.2 native build,
Go 1.26.4 linux/amd64, GOMAXPROCS=2 and build parallelism 1. Main CI evidence is
not substituted for branch-specific checks.

Baseline retains the exact cherry-picked tests and reverses only the production
function change:

  • Handler-fed history: 0/1/2 transferred deletes pass; 3/8 fail with no row.
  • Real TAE -> Flush/transfer -> logtail -> SQL: 14/16 checks correct. After the
    third controlled Flush commit, exact SELECT and FOR UPDATE return no rows;
    prefix/full return (3,1) in the same fixed SI transaction, with no SQL error.

Patched candidate:

  • Identical SQL oracle: 16/16 checks pass, body 0.53s.

  • Full pkg/vm/engine/disttae/logtailreplay: PASS, 0.278s.

  • Full pkg/vm/engine/test: PASS, 155.151s.

  • Four existing skipped tests remain skipped, not credited as passes.

  • Three-sample microbench medians (ns/op):

    History Original Patched
    1 version, live 409.4 419.6
    1 version, deleted 440.0 424.4
    100 versions, live 735.9 506.3
    100 versions, deleted 543.0 513.9
    10000 versions, live 972.8 670.1
    10000 versions, deleted 708.2 684.2
  • 1024 preceding transferred deletes: 10.998 us median, fixed 810 B /
    10 allocations per lookup. The one-version live median is +2.5% in this short
    shared-host test; this is not a full-workload performance guarantee.

  • Full two-package golangci-lint from the branch-pinned v2.6.2 source, built with
    Go1.26.4 and using unchanged .golangci.yml: PASS, 0 issues. No new filters
    or exclusions. An initial Go1.27-built linter produced a formatter mismatch
    on an unchanged file; it was corrected by matching the toolchain, not by
    changing unrelated code.

  • Final scope-aware self-review, branch-native gofmt and git diff --check pass.

  • GitHub CI for this backport is separate and must still pass before merging.

Evidence boundaries

The SQL fixture holds three real Flush commits and passes no source tombstone
objects. It bypasses automatic flusher admission/order and uses EnginePack's
test RPC/lock adapters. Normal automatic-scheduler reachability/frequency is not
proved. This is not a production multi-CN reproduction, proof of durable loss,
or a claim that #32515 has been diagnosed/fixed.

Skipped-delete work is linear in the same-key prefix. There is no new per-entry
allocation/I/O/wait, and ordinary update history terminates after the newest
insertion. Microbenchmarks do not guarantee production tail latency.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify

mergify Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Queue requested — the merge queue status continues in this comment ↓.

@XuPeng-SH

XuPeng-SH commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 3eb60dddf21c46b717e0bdf7274cc46754f7a735

Review completed. Read the assessment.

@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: 3eb60dddf21c46b717e0bdf7274cc46754f7a735

Assessment: approve

The backport restores exact unique-PK reads across transferred deletes while preserving snapshot visibility and complete physical-row delete iteration. Iterator-local termination reuses existing validation and avoids scanning obsolete insertion history; no actionable defect remains.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Reviewed the complete three-file delta, primary-key producers/readers/GC, scheduler boundaries, linked issue and all PR discussion; saved the review plan and discussion assessment.

  • Branch-matched Go 1.26.4, native prerequisites and isolation preflight passed. Full logtailreplay package: 321 test/subtest passes, one existing skip. Controlled SQL regression: all 16 checks passed.

  • Baseline production-function overlay retained identical candidate tests: 0/1/2-transfer controls passed; 3/8-transfer cases failed. Only the final-stage exact SELECT and FOR UPDATE missed the row; prefix/full controls passed.

  • Clean-source, whitespace and formatting checks passed. All local claims are matched to terminal receipts and retained logs in validation-evidence.json; supplied exact-head branch CI also reports successful build, UT/coverage, SCA and multi-CN BVT.

Limitations:

  • The SQL fixture controls Flush commits and uses test RPC/lock adapters; it does not establish automatic-scheduler frequency, production multi-CN behavior or resolution of allocator incident #32515.

  • The full engine/test suite, author lint and microbenchmarks were not independently rerun locally.

@mergify mergify Bot added the queued label Nov 14, 2026
@mergify

mergify Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into 4.2-dev as d793123 at 08:46 UTC

1 h 39 min in the queue, 50 min of it CI.

So far

  • ✅ Entered the queue Sat 14 Nov, 07:07 · rule release-4.2 · triggered by rule Automatic queue on approval for release-4.2
  • ✅ Passed · in place
  • ✅ Merged 08:46 · d793123 · squash
3 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection
  • any of · required by GitHub branch protection:
    • check-success = CI Required
    • check-neutral = CI Required
    • check-skipped = CI Required

Times in UTC · dashboard · how the merge queue works

This branch was previously deployed

1 inactive deployment
ci — 130a176d Deployed Nov 14, 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 size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants