Skip to content

fix(frontend): honor zero data branch diff limits - #26540

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-26034
Aug 1, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-26034

Conversation

@gouhongshen

@gouhongshen gouhongshen commented Jul 31, 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:

Fixes #26034

What this PR does / why we need it:

DATA BRANCH DIFF ... OUTPUT LIMIT 0 appended the first diff row before checking whether the output limit had already been reached. As a result, a valid zero limit returned one row.

This PR:

  • centralizes the row-limit predicate and evaluates it before consuming rows, stopping producers immediately when the limit is zero while retaining the existing channel-drain and batch-recycle protocol;
  • adds a focused unit test for limits 0, 1, the exact row count, and a limit above the row count, including producer-stop behavior;
  • adds BVT coverage for zero limits with and without column projection, plus adjacent and upper boundaries;
  • makes the LIMIT 1 BVT setup deterministic by testing it while exactly one row differs. This avoids asserting which row an unordered multi-row diff produces first while preserving the row-count boundary coverage.

CI follow-up:

  • The first PESSIMISTIC BVT run failed because the new LIMIT 1 case expected row id=1, while the unordered diff validly returned id=2. The test setup now has exactly one differing row at that boundary.
  • The Coverage job in that workflow was a dependent failure (coverage merge skipped because at least one required producer was skipped or failed), not an independent product failure.

Validation:

  • GOWORK=off go build -mod=readonly ./pkg/frontend
  • GOWORK=off go vet -mod=readonly ./pkg/frontend
  • .agents/skills/mo-dev/scripts/mo-cgo-test -race -json -count=1 -timeout=120s -run '^TestDataBranchOutputLimitBoundaries$' ./pkg/frontend
  • focused race stress: T=0.01s, B=30s, N=100; all 100 runs passed
  • .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/frontend
  • BVT branch_output_limit_zero: 15/15 statements passed at 100% in each of 5 consecutive runs; generated output was manually checked for 0/1/4/5 row semantics

Residual risk: none known. Parsing and positive-limit semantics are unchanged; negative limits remain parser-rejected. Diff row order remains unspecified, and the regression test does not impose an ordering contract.

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

Deep-reviewed exact head 7ee5091. The boundary predicate is now evaluated before row consumption, so LIMIT 0 is correct without changing positive-limit semantics. Lifecycle closure is intact: stop is sync.Once-guarded, producers observe stopCh both before and during send, the consumer keeps draining retCh, every queued batch is recycled, the producer closes out before retCh is closed, and both goroutines are waited. The BVT also avoids imposing an order on unordered diff output. No blocking correctness, leak/hang/double-close, compatibility, or performance issue found. Local verification: focused boundary test under race count=100, full pkg/frontend under race, scoped go vet, diff check, latest CI green.

@XuPeng-SH
XuPeng-SH merged commit 34fdf9d into matrixorigin:main Aug 1, 2026
23 of 25 checks passed
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Fixes matrixorigin#26034

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

`DATA BRANCH DIFF ... OUTPUT LIMIT 0` appended the first diff row before
checking whether the output limit had already been reached. As a result,
a valid zero limit returned one row.

This PR:

- centralizes the row-limit predicate and evaluates it before consuming
rows, stopping producers immediately when the limit is zero while
retaining the existing channel-drain and batch-recycle protocol;
- adds a focused unit test for limits 0, 1, the exact row count, and a
limit above the row count, including producer-stop behavior;
- adds BVT coverage for zero limits with and without column projection,
plus adjacent and upper boundaries;
- makes the `LIMIT 1` BVT setup deterministic by testing it while
exactly one row differs. This avoids asserting which row an unordered
multi-row diff produces first while preserving the row-count boundary
coverage.

CI follow-up:

- The first PESSIMISTIC BVT run failed because the new `LIMIT 1` case
expected row `id=1`, while the unordered diff validly returned `id=2`.
The test setup now has exactly one differing row at that boundary.
- The Coverage job in that workflow was a dependent failure (`coverage
merge skipped because at least one required producer was skipped or
failed`), not an independent product failure.

Validation:

- `GOWORK=off go build -mod=readonly ./pkg/frontend`
- `GOWORK=off go vet -mod=readonly ./pkg/frontend`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -json -count=1
-timeout=120s -run '^TestDataBranchOutputLimitBoundaries$'
./pkg/frontend`
- focused race stress: `T=0.01s`, `B=30s`, `N=100`; all 100 runs passed
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1
-timeout=300s ./pkg/frontend`
- BVT `branch_output_limit_zero`: 15/15 statements passed at 100% in
each of 5 consecutive runs; generated output was manually checked for
0/1/4/5 row semantics

Residual risk: none known. Parsing and positive-limit semantics are
unchanged; negative limits remain parser-rejected. Diff row order
remains unspecified, and the regression test does not impose an ordering
contract.

---------

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Fixes matrixorigin#26034

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

`DATA BRANCH DIFF ... OUTPUT LIMIT 0` appended the first diff row before
checking whether the output limit had already been reached. As a result,
a valid zero limit returned one row.

This PR:

- centralizes the row-limit predicate and evaluates it before consuming
rows, stopping producers immediately when the limit is zero while
retaining the existing channel-drain and batch-recycle protocol;
- adds a focused unit test for limits 0, 1, the exact row count, and a
limit above the row count, including producer-stop behavior;
- adds BVT coverage for zero limits with and without column projection,
plus adjacent and upper boundaries;
- makes the `LIMIT 1` BVT setup deterministic by testing it while
exactly one row differs. This avoids asserting which row an unordered
multi-row diff produces first while preserving the row-count boundary
coverage.

CI follow-up:

- The first PESSIMISTIC BVT run failed because the new `LIMIT 1` case
expected row `id=1`, while the unordered diff validly returned `id=2`.
The test setup now has exactly one differing row at that boundary.
- The Coverage job in that workflow was a dependent failure (`coverage
merge skipped because at least one required producer was skipped or
failed`), not an independent product failure.

Validation:

- `GOWORK=off go build -mod=readonly ./pkg/frontend`
- `GOWORK=off go vet -mod=readonly ./pkg/frontend`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -json -count=1
-timeout=120s -run '^TestDataBranchOutputLimitBoundaries$'
./pkg/frontend`
- focused race stress: `T=0.01s`, `B=30s`, `N=100`; all 100 runs passed
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1
-timeout=300s ./pkg/frontend`
- BVT `branch_output_limit_zero`: 15/15 statements passed at 100% in
each of 5 consecutive runs; generated output was manually checked for
0/1/4/5 row semantics

Residual risk: none known. Parsing and positive-limit semantics are
unchanged; negative limits remain parser-rejected. Diff row order
remains unspecified, and the regression test does not impose an ordering
contract.

---------

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Fixes matrixorigin#26034

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

`DATA BRANCH DIFF ... OUTPUT LIMIT 0` appended the first diff row before
checking whether the output limit had already been reached. As a result,
a valid zero limit returned one row.

This PR:

- centralizes the row-limit predicate and evaluates it before consuming
rows, stopping producers immediately when the limit is zero while
retaining the existing channel-drain and batch-recycle protocol;
- adds a focused unit test for limits 0, 1, the exact row count, and a
limit above the row count, including producer-stop behavior;
- adds BVT coverage for zero limits with and without column projection,
plus adjacent and upper boundaries;
- makes the `LIMIT 1` BVT setup deterministic by testing it while
exactly one row differs. This avoids asserting which row an unordered
multi-row diff produces first while preserving the row-count boundary
coverage.

CI follow-up:

- The first PESSIMISTIC BVT run failed because the new `LIMIT 1` case
expected row `id=1`, while the unordered diff validly returned `id=2`.
The test setup now has exactly one differing row at that boundary.
- The Coverage job in that workflow was a dependent failure (`coverage
merge skipped because at least one required producer was skipped or
failed`), not an independent product failure.

Validation:

- `GOWORK=off go build -mod=readonly ./pkg/frontend`
- `GOWORK=off go vet -mod=readonly ./pkg/frontend`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -json -count=1
-timeout=120s -run '^TestDataBranchOutputLimitBoundaries$'
./pkg/frontend`
- focused race stress: `T=0.01s`, `B=30s`, `N=100`; all 100 runs passed
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1
-timeout=300s ./pkg/frontend`
- BVT `branch_output_limit_zero`: 15/15 statements passed at 100% in
each of 5 consecutive runs; generated output was manually checked for
0/1/4/5 row semantics

Residual risk: none known. Parsing and positive-limit semantics are
unchanged; negative limits remain parser-rejected. Diff row order
remains unspecified, and the regression test does not impose an ordering
contract.

---------

Co-authored-by: XuPeng-SH <[email protected]>

This branch was previously deployed

1 inactive deployment
ci — e6666c55 Deployed Aug 1, 2026 by XuPeng-SH via Matrixone Utils CI / Coverage #43944
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.

[Bug]: DATA BRANCH DIFF OUTPUT LIMIT 0 returns one row

3 participants