Skip to content

Fix vector shuffle ownership and sorted metadata - #32020

Merged
mergify[bot] merged 8 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/9a1e4e347d325bfb2646f3555a38169d58d509fce4a784b85c42b8db4d9453de
Nov 2, 2026
Merged

mergify[bot] merged 8 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/9a1e4e347d325bfb2646f3555a38169d58d509fce4a784b85c42b8db4d9453de

Conversation

@iamlinjunhong

@iamlinjunhong iamlinjunhong commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

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

Which issue(s) this PR fixes:

What this PR does / why we need it:

Shuffle now retires borrowed data ownership correctly while preserving retained views and shared varlen area ownership. It prepares data and bitmap replacements before committing, so allocation failures leave the original vector intact. It also preserves the sorted flag only when the selected indices prove the order remains nondecreasing, preventing consumers from relying on an invalid sorted flag.

Owned, equal-length ShuffleWithBuf vectors with uniform metadata now skip row-sidecar preparation and cleanup. The same typed payload/bitmap permutation handles both uniform and mixed metadata, retaining sorted and varlen-area property updates.

Validation at e70a3b3a60127002a2da12762bcd624a853e9dde (Go 1.27.1, Darwin/arm64):

  • Newly run with .agents/skills/mo-dev/scripts/mo-cgo-test: full vector and mergeutil suites, TestBetweenAfterShuffleInvalidatesSorted through the real consumer, and the full vector race suite, all passed. Four new controls cover uniform metadata and each per-row sidecar, plus values, NULL/grouping, scalar metadata and pool cleanup.
  • Three-package go vet, vector incremental golangci-lint, formatting and delivery-artifact checks passed.
  • Parent-head CI passed in run 41409152919; its unmodified ownership/lease evidence is reused. CI for this repair commit has not run yet.

Performance: compared with a frozen f0a6ed145e07c84ecc80566ac659212c4a20debd vector.go-only overlay using the same benchmark and other compiler inputs. One warm-up and four alternating paired rounds, 2 seconds per measured case, GOMAXPROCS=1: 8192-row unsorted buffered int64 median 4377.5 → 4311.5 ns/op (-1.51%); varchar 7520.0 → 7453.5 ns/op (-0.88%). Both 64-row controls were faster, and every sample retained 0 B/op and 0 allocs/op. The paired log-ratio model's 95% interval for int64 was [-5.59%, +1.42%]. These are local component measurements on a shared host, not an end-to-end SQL result. Sorted vectors still require the nondecreasing-selection scan; its consumer net benefit remains unmeasured.

@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 →

@XuPeng-SH

XuPeng-SH commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: e70a3b3a60127002a2da12762bcd624a853e9dde

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: e70a3b3a60127002a2da12762bcd624a853e9dde

Assessment: approve

Ownership, failure-atomicity and metadata behavior are covered. The revised buffered path passes functional validation; the earlier performance finding was not consistently reproduced at this head. No confirmed actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a1869d-999c-7481-b340-ae4a63e8cee4 · slot 1 · generation 2

Validation:

  • Full vector suite passed: 343 top-level tests, no skips. Receipt: checks/1793639496393945207-2.json; vector-tests-final.log.

  • Four alternating benchmark pairs used identical inputs except the frozen base vector.go overlay. All samples retained zero allocations; results and receipts are recorded in benchmark-analysis.json and validation-evidence.json.

  • Six-file review, formatting, clean source and all five discussion keys verified. Receipt: checks/1793640004170836066-2.json; review-audit.log.

  • Frozen-head CI reports 13 successful, 14 skipped and 2 neutral checks.

Limitations:

  • Large-int64 performance remains inconclusive: median +3.30%, with a paired model interval of -2.14% to +17.88%. This proves neither equivalence nor a repeatable material regression.

  • No fresh local race or dependent-package runs; relevant supplied review and CI evidence was reused.

  • No end-to-end SQL performance measurement; author benchmark raw logs were unavailable.

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

mergify Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as cd40f4e at 18:24 UTC

1 h 3 min in the queue, 1 h 2 min of it CI.

So far

  • ✅ Entered the queue Mon 2 Nov, 17:21 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Passed · in place
  • ✅ Merged 18:24 · cd40f4e · 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

@mergify
mergify Bot merged commit cd40f4e into matrixorigin:main Nov 2, 2026
@mergify mergify Bot removed the queued label Nov 2, 2026
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Nov 2, 2026
…stream claimed 97 as narrow_scan in matrixorigin#32034); take upstream narrow-scan prefetch, virtual-timestamp reads, temporal integer casts, vector shuffle ownership, JSON concat and logtail append-range changes

GitHub reported the PR CONFLICTING (DIRTY): upstream matrixorigin#32034 added
`plan.Node.narrow_scan = 97` while this branch's unmerged additive
`ScanReadRole scan_read_role` sat on field 97.

Semantic resolution, both sides kept:
- upstream keeps `narrow_scan = 97` (shipped on main;
  `plan.pb.go` regenerated from the merged proto with the repository
  protoc/gogofast pipeline plus both postprocessors; toolchain verified
  byte-identical against upstream's committed bindings before use);
- this branch's additive `scan_read_role` moves 97 -> 98; nothing ever
  persisted 97 as scan_read_role (unmerged field), provenance comment
  updated in proto/plan.proto;
- `merged_descriptor_test.go` (upstream's merge-collision contract
  guard) extended to pin Node.narrow_scan=97 / Node.scan_read_role=98
  so a future regeneration cannot silently renumber or drop either;
- all other overlapping files auto-merged with both sides' hunks intact
  (upstream: table_scan/narrow-scan scope+operator plumbing, plan binder
  temporal/int-arg changes, disttae datasource, query_builder/types/
  deepcopy/base_binder/apply_indices).

Upstream batch: matrixorigin#31268 (virtual timestamp reads), matrixorigin#32001 (temporal
integer casts), matrixorigin#32020 (vector shuffle ownership), matrixorigin#32031 (logtail
append ranges), matrixorigin#32038 (python JSON-string concatenation; upstream's
own change, no PR-side code), matrixorigin#32034 (narrow-scan prefetch).
XuPeng-SH pushed a commit that referenced this pull request Nov 4, 2026
## 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:

- #32016

## What this PR does / why we need it:

Follow-up to merged #32020: preserve its Shuffle ownership,
failure-atomicity and sorted-metadata fixes while reducing
ordering-proof and identity-copy overhead. The issue's QA found an
ascending buffered Shuffle component benchmark regression after the
original fix; the original lease leak and sorted correctness failures
were no longer reproduced in its covered main paths. This change
combines the ordering proof with gathering and avoids the identity
copy-back only when the actual data and scratch ranges do not overlap.

Validation at the final candidate: vector and function owning suites and
targeted mergeutil tests passed; identity alias and byte-overlap
boundary tests, gofmt, affected-package vet, incremental lint and `git
diff --check` passed. Prior race evidence applies to the unchanged owner
protocol. Full CI is pending.

In a shared-machine component benchmark, the 8192-row fixed buffered
ascending fixture improved 30.52% against a restricted pre-fix function
overlay (10 paired samples, 90% CI −31.23% to −29.81%; both 0
allocations). This is not an end-to-end or production SQL measurement.
The 64-row descending control showed a +0.72% signal against the
preceding candidate (5 pairs, 90% CI +0.05% to +1.40%); its cause and
production impact are unestablished, and the review accepted it as a
non-blocking limitation, not proof of equivalence.

General non-identity overlap between scratch and data remains
unsupported as a correct in-place gather: this change can alter the
erroneous output of an already incorrect overlapping call. Identity
overlap retains the two-copy behavior; callers should use independent
scratch for general selections.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
ci — 08968d08 Deployed Nov 2, 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/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants