Skip to content

fix(compile): partition generate_series offsets across CNs - #27069

Merged
XuPeng-SH merged 7 commits into
matrixorigin:mainfrom
XuPeng-SH:fix-generate-series-cn-offset-partitions
Aug 13, 2026
Merged

XuPeng-SH merged 7 commits into
matrixorigin:mainfrom
XuPeng-SH:fix-generate-series-cn-offset-partitions

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

What this fixes

compileGenerateSeriesParallel assigned every CN from the first offset segment because the shared offset cursor never advanced. With two CNs this duplicated the first segment and omitted later values.

Change

  • advance the offset cursor after assigning each CN
  • add a white-box regression with heterogeneous CN CPU capacities
  • strengthen the distributed SQL oracle to assert count, min, max, and distinct count so duplicate/missing ranges cannot cancel out

This correctness fix was isolated while rescoping #26109; it is independent of the rejected workload-policy model.

Validation

  • unfixed counterexample: new focused test fails because CN 2 receives offsets 1..200000 instead of 200001..400000
  • focused test: PASS
  • focused race stress (-race -count=50): PASS
  • full ./pkg/sql/compile: PASS
  • full ./pkg/sql/compile under race: PASS
  • go build ./pkg/sql/compile: PASS
  • go vet ./pkg/sql/compile: PASS

The multi-CN SQL regression is included for CI execution.

@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

Copy link
Copy Markdown
Contributor Author

Deep self-review at exact head 969c2fcc29: no blocking findings.

The one-line cursor advance closes the relevant invariant: each generated parallel offset is assigned to exactly one per-CN-derived scope. The second scope now receives the next slice, while parallelSize decrement keeps startOffset + currMcpu bounded by len(offset).

Validation:

  • the focused white-box regression passes on this head and fails unchanged on base ca73de9eec for the claimed reason (scope 2 receives offsets 1..200000 instead of 200001..400000);
  • full ./pkg/sql/compile, focused -race -count=20, go list, go build, go vet, and git diff --check pass;
  • the multi-CN BVT job selected table_func_generate_series.test and passed; count/min/max/distinct jointly prove the exact 1..200000 result set;
  • latest main@0fc87ec145 merges cleanly and the focused regression still passes.

The existing local-address placement and non-unit/descending-step partition behavior are independent pre-existing concerns outside this cursor-fix diff; this change neither introduces nor expands them.

GitHub does not allow XuPeng-SH to formally approve a PR authored by the same account, so this comment records the no-blocker review decision.

@XuPeng-SH
XuPeng-SH merged commit bb29bdb into matrixorigin:main Aug 13, 2026
23 of 24 checks passed
@XuPeng-SH
XuPeng-SH deleted the fix-generate-series-cn-offset-partitions branch August 13, 2026 16:40
XuPeng-SH added a commit that referenced this pull request Sep 8, 2026
…-owned scheduling (#26109)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [x] Improvement
- [x] Documentation
- [ ] Feature
- [x] Test and CI
- [x] Code Refactoring

## Which issue(s) this PR fixes

Related to #25451. This does **not** close the canonical compute-group
implementation gate.

## Outcome and scope

Rebased on `main` at `0b195e4f5a23c06a40552a8db3e7fdf182979a3a`.
Latest repair: `6a96463a66`.

This PR separates a **draft** canonical compute-group RFC/acceptance
matrix from
independently useful legacy ingress-scheduling and LOCAL-upload
correctness
fixes. It does not implement compute-group identity, authorization,
admission,
or the future distributed drain protocol. The rejected workload-policy
DDL/catalog/RPC/cache and raw-label product model remain removed. RFC
owner
approval and Milestone-B implementation/validation remain separate
gates.

## Implementation

- Writable AP workspaces retain ingress participation. LOCAL input is
  ingress-only and is allocated only after successful compile/placement.
- General vector-index scan IR from current main retains the
ingress/ordinal
  invariant; no resurrection of the removed IVF-only function-scan IR.
- Exact service ID wins over aliases; local routes use the real ingress
address. Authoritative empty/excluded/draining pools fail closed rather
than
  manufacturing local membership.
- Interrupted LOCAL upload now terminates at the **network protocol
boundary**:
cancel interrupts both pipe and network I/O; cleanup joins the watcher
and
  producer before freeing buffers or reusing session/ExecCtx state.
- Removed unbounded discard-to-EOF and consecutive-error retries. Packet
retries cannot reconstruct a partially consumed frame, and successful
packets
  previously reset the error budget indefinitely.
- UDF file import shares the same repaired lifecycle. Storage write
errors and
panics cancel the producer before joining; its duplicate watcher is
removed.
- Compatibility tradeoff: a failed/canceled upload before protocol EOF
closes
its client connection; clients must reconnect. Successful EOF retains
normal
connection reuse. No successful-upload size cap or per-row cache is
added.

## RFC correction

DrainRequested publication is not a distributed claim barrier. The
authority
must collect generation/incarnation-fenced receiver seals, serialized
against
local/remote claim admission, before publishing effective Draining. A
stale
Ready cache and valid lease cannot bypass an acknowledged seal. Missing
acks
produce bounded pending/failure responses and retain DrainRequested, not
false
success. Lease expiry alone cannot stand in for an acknowledgement;
permanently
lost participants require a separately reviewed execution-fencing
protocol.
This explicitly trades drain availability for a clock-independent safety
rule.

## Test plan

### Automated regression and static checks

- [x] Full `./pkg/frontend` normal: 25.795s; full race: 41.427s.
- [x] Focused protocol tests: pre-cancel, invalid config, blocked
request write,
idle read, partial header/body, blocked pipe, pipe failure, disconnect,
EOF,
  next-command reuse after late cancel, and allocator balance.
- [x] Runner error/panic and UDF storage error/panic prove cleanup does
not wait
  for client EOF, with exactly-once disconnect/free assertions.
- [x] Each lifecycle test received its own `-race -count=100` run; final
focused
race also includes the added allocator-balance assertions. No repeated
full
  package stress.
- [x] `go vet` via controlled CGo wrapper `-vet=all -run '^$'`; ordinary
package
execution evidence is recorded separately above. `gofmt`, `git diff
--check`,
  and Python AST parsing pass.
- [x] Reuse unchanged rebase evidence: schedule full suite, compile
focused
`TestScheduleQueryWorkers`, and placement A/B benchmarks against the
same main.
- [ ] Full compile suite is **not green** in this environment: five
Parquet
fanout tests fail identically on clean main `0b195e4f5a` with matched
native
  inputs. They are not attributed to this PR and are not hidden/skipped.

### Real service: 10.222.1.55, two CNs

- [x] Final normal binary SHA-256:
  `b076571701a5ae6b38733d22f5e23e4527fcdf90b5bdb6a312441c3a8750d6b4`.
- [x] On both ingress ports: two committed rows plus one uncommitted
row;
  read-your-writes, peer isolation and rollback; normal LOCAL result and
  subsequent command on the same connection.
- [x] KILL QUERY with **no upload EOF**: idle client, incomplete header,
incomplete body and continuing packet sender; server closes connection
and
aborted LOAD leaves no rows. UDF import cancellation publishes no
function.
- [x] Final normal witness passes twice on the same instance; each run
verifies
database teardown. Service was stopped afterward; no local mo-service
started.
- [x] Separate white-box build enables existing
`SetForceScanOnMultiCN(true)`
only after SQL/ISCP readiness; the LOAD/transaction witness passes twice
with
the same tiny data. This is injection evidence, not normal performance.
  Temporary injection code is removed and is not in the commit.
- [x] An initial always-on injection interfered with bootstrap discovery
and
failed required-ingress placement. That run is excluded, its data
quarantined,
  and the successful gated injection used a fresh data directory.

QA reproduction is committed under
`optools/testdata/load_local_lifecycle/README.md` and `validate.py`.
Use only a disposable test-owned two-CN instance, never
shared/production data.
Retained run logs: `/mnt/nvme/xupeng/pr26109-validation.TZpKhg` on 55.

### Performance and limitations

Placement allocation profile is unchanged from clean main: all-workers
`10192 B/op, 7 allocs/op`; max-workers `11600 B/op, 9 allocs/op`. Three
short
samples showed no obvious latency regression, but do not establish a
<=2%
p50/p95 or end-to-end SQL performance gate. LOCAL repair removes
failure-path
work and a redundant UDF watcher, without changing normal per-packet
payload
allocation. Future compute-group benchmarks/acceptance remain unclaimed.

CI is not awaited as part of this delivery. The separate generate_series
offset
defect remains tracked by #27069.

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants