Skip to content

fix(ivfflat): preserve candidate ownership across flush replay - #33154

Merged
XuPeng-SH merged 7 commits into
matrixorigin:mainfrom
LeftHandCold:fix/33149-ivf-flush-ownership
Nov 25, 2026
Merged

XuPeng-SH merged 7 commits into
matrixorigin:mainfrom
LeftHandCold:fix/33149-ivf-flush-ownership

Conversation

@LeftHandCold

@LeftHandCold LeftHandCold commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • BUG
  • Test and CI

Which issue(s) this PR fixes

Refs #33149 (main implementation; #33153 is the 4.2 companion).

What this PR does / why we need it

At the same read snapshot, two CNs can have applied different parts of the flush logtail. One can see an IVF entry in replay memory and the other can see the same entry in the old appendable object's file with its original commit timestamp. Assigning replay rows to the memory owner but assigning the appendable file by ObjectID can return the entry twice, or not at all. The historical Top‑10 observation did not retain per-CN candidate RowIDs; the deterministic storage test demonstrates the failure mechanism independently.

Check the appendable flag before the IVF ObjectID hash in the existing storage shuffle predicate. Both representations follow the existing replay-memory reader (IsLocalCN); immutable objects still use the full ObjectID hash. Non-IVF shuffle and single-reader behavior are unchanged. There is no post-LIMIT deduplication, index format change, new MORPC version, protobuf marker, query-wide peer probe, or old-peer fallback. Existing protocol checks for executed scans and their session knobs remain unchanged from main.

Verification

  • Storage regression with real replay rows, flushed appendable file and later immutable replacement; both mixed replay orders and both aligned controls.
  • Compiler regression with a failing peer: a partitionable IVF scan beneath literal LIMIT 0 compiles without a peer probe; the LIMIT 1 control still propagates the peer error. Placement coverage switches ingress with two and three workers.
  • Two-CN SQL regression: exact ordered primary keys from both ingress CNs, remote execution in the physical plan, and transaction rollback/commit checks.

@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 24, 2026 •

Copy link
Copy Markdown
Contributor

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

@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: 09ff6b55b3276c60e31ac7f1b9c9fd01d727881f

Assessment: request_changes

The focused mixed-replay storage test passes, but the new RPC version and legacy ownership path violate the target branch’s upgrade contract. The associated query-wide probe also creates an avoidable failure path for scans that will not execute.

Model: gpt-6.1-terra / max

Session: 01a21155-55c0-79f0-b683-78fb22f78abd · slot 1 · generation 13

  • P2 pkg/defines/const.go:173: An AP multi-CN query containing a partitionable IVF scan triggers the new MORPC 135 capability check, including when the scan is beneath an outer literal LIMIT 0.
    Impact: The target branch supports shutdown-only upgrades and prohibits new per-feature MORPC versions, peer capability checks, and old-peer fallbacks. The added marker and legacy branch maintain two ownership modes for an unsupported mixed-binary deployment. The eager check also returns a peer query-service error before the compiler can skip a zero-limit subtree, so an otherwise empty query can fail because of an unused peer.
    Evidence: The pinned .agents/skills/mo-dev/references/upgrade-compatibility.md:94 states the in-cluster rule. The new version is required by pkg/sql/colexec/vectorscan/protocol.go:29, and unmarked plans retain legacy ownership in pkg/vectorindex/ivfflat/plan_reader.go:112. The retained planner probe shows an AP multi-CN IVF scan below LIMIT 0; pkg/sql/compile/compile.go:1528 invokes the new check before the zero-limit shortcut at pkg/sql/compile/compile.go:2022, and pkg/sql/compile/vector_scan_protocol.go:190 returns probe errors. Route appendable objects to the existing IsLocalCN memory owner before object-ID hashing, preserving immutable-object hashing, and remove the new version, marker, and older-peer negotiation while retaining unrelated existing gates.

Validation:

  • The private /tmp and loopback preflight passed; see preflight.log and checks/1795593630014682727-2.json.

  • TestIVFFlushPreservesPartitionOwnership passed on retry, including both mixed replay orders and both aligned controls; see ivfflat-test-retry.log and checks/1795596157457609453-2.json. The first run timed out during compilation.

  • The generated protobuf descriptor matched the merge-base descriptor after removing the new optional field 25; see descriptor-probe.log and checks/1795593962787953238-2.json.

  • A temporary planner probe using SQL and mock table fixtures confirmed the zero-limit and decimal-expression plan shapes; see placement-plan-probe.log and checks/1795596483284370006-2.json.

Limitations:

  • The planner probe did not execute a live peer failure; that consequence follows from the cited compiler and probe error paths.

  • The author-reported two-CN SQL run and owning-suite results were not backed by retained execution logs in the supplied evidence and were not independently rerun.

Assign flushed appendable objects to the existing memory owner before IVF ObjectID hashing. Keep the base scan protocol and the immutable hash unchanged; no new wire marker or query-wide capability probe is needed. Cover pruned scans with an unavailable peer and both mixed flush replay orders.
@LeftHandCold

Copy link
Copy Markdown
Collaborator Author

Addressed the requested change in 20513817ca.

The only production behavior delta against the PR base is in ShouldSkipObjByShuffle: handle appendable objects via IsLocalCN before immutable ObjectID hashing. No MORPC 135, protobuf/descriptor change, wire flag, new peer probe or fallback remains. The existing scan and session-knob protocol checks are unchanged from main.

Check Before Updated head
Multi-CN compile, peer query service returns an error, outer literal LIMIT 0 On the reviewed head 09ff6b55b3, TestPrunedVectorScanDoesNotProbePeer/pruned fails with peer query service unavailable Compiles; zero peer requests. The LIMIT 1 control still calls the peer and propagates its error.
Same-snapshot replay / old appendable file, one logical entry With base ownership, ingress-before/peer-after includes an extra peer copy; the reverse order misses the entry All four replay combinations pass, one expected PK; the later immutable replacement still belongs to the hashed peer.
Real two-CN SQL, switch ingress 0 → 1 → 0 — TestIssue29226VectorScanAcrossCoordinators passed (6.93 s). The executed plan included the peer on each run, each returned IDs [1,2,3,4,5,6], and the transaction rollback/commit assertions passed.

The full compile, plan, ivfflat, engine, and vectorscan package tests passed, in addition to focused checks. Scoped go vet passed and golangci-lint 2.14.0 reported 0 issues. The PR description now describes the single ownership rule. Ready for re-review.

@XuPeng-SH

XuPeng-SH commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 20513817ca11439df0d1b211e8e84c2a5e8d7efb

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: 20513817ca11439df0d1b211e8e84c2a5e8d7efb

Assessment: approve

The revised fix assigns appendable IVF files to the existing replay-memory owner and retains ObjectID hashing for immutable files. Compiler placement keeps the coordinator in a partitioned scan, and the single-CN and local-parallel paths retain one memory owner. This corrects the mixed-replay ownership boundary without adding a second ownership protocol. The prior review's new RPC gate, fallback, and eager probe are removed.

Model: gpt-6.1-terra / max

Session: 01a2110f-4081-7e00-8415-e36a337ad118 · slot 0 · generation 12

Validation:

  • Reviewed the complete delta, linked issue and discussion, and traced compiler placement through IVF reader identity and storage range filtering. The new storage test covers both mixed replay orders, aligned states, a single-CN control, and a later immutable object; compiler tests cover ingress placement and LIMIT 0 versus LIMIT 1.

  • The exact-head CI snapshot reports successful Ubuntu/x86 unit, arm64 static analysis, enabled proxy and pessimistic multi-CN BVT, and CI Required checks. The author reports focused storage and compiler runs and a two-CN SQL run with exact keys and transaction controls.

  • Private-runtime preflight and git diff --check passed; see preflight.log, diff-check.log, and receipts checks/1795611134611871181-2.json and checks/1795611134557974368-2.json.

Limitations:

  • No local Go package or live two-CN SQL run was repeated. The author's updated-head focused runs have no retained execution logs in local_validation; CI success is reported at job level. The older review's storage run is evidence for its own prior head only.

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

mergify Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue · pull request dequeued

27 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Wed 25 Nov, 12:54 · rule main · triggered by rule Automatic queue on approval for main
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 13:21 · 301070a

Reason

Pull request #33154 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

To get back in the queue

  • Push a change if one is needed: the pull request is queued again once its queue conditions match.
  • If no change is needed, tick the box below to queue it again as it is.

Merge conditions not met when it left the queue

  • any of · required by GitHub branch protection:
    • check-neutral = CI Required
    • check-skipped = CI Required
    • check-success = CI Required

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request
2 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection

Times in UTC · dashboard · how the merge queue works

This branch was successfully deployed

No deployments
ci — 301070ae Deployed Nov 25, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued kind/bug Something isn't working kind/test-ci 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