Repository navigation
fix(frontend): honor zero data branch diff limits - #26540
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
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.
## 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]>
## 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]>
## 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]>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #26034
What this PR does / why we need it:
DATA BRANCH DIFF ... OUTPUT LIMIT 0appended 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:
LIMIT 1BVT 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:
LIMIT 1case expected rowid=1, while the unordered diff validly returnedid=2. The test setup now has exactly one differing row at that boundary.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/frontendGOWORK=off go vet -mod=readonly ./pkg/frontend.agents/skills/mo-dev/scripts/mo-cgo-test -race -json -count=1 -timeout=120s -run '^TestDataBranchOutputLimitBoundaries$' ./pkg/frontendT=0.01s,B=30s,N=100; all 100 runs passed.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/frontendbranch_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 semanticsResidual 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.