Repository navigation
fix: avoid mutating shared batches in limit - #26498
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 review completed at b4e7179. No blocking findings.
Verified the LIMIT ownership fix preserves the shared input batch, keeps the copied terminal batch operator-owned across Reset, and releases it exactly once in Free. The added regression test covers input immutability and metadata preservation; the ISCP test cleanup is idempotent.
Local validation passed: focused tests with race repetitions (100x/100x/25x), full owning-package race tests, build, vet, and non-race tests for limit, engine/test, compile, and pipeline.
Merge Queue Status
This pull request spent 36 minutes 57 seconds in the queue, including 36 minutes 13 seconds running CI. Required conditions to merge
|
`LIMIT` truncated its input batch in place. Recursive CTE pipelines can fan out the same batch to multiple consumers, so one consumer could shorten the vectors while another consumer still observed the original row count. This caused downstream expression evaluation to access rows beyond the shortened vector and panic. This change: - copies the final truncated batch into a buffer owned by the `Limit` operator; - keeps the shared upstream batch immutable; - releases the owned buffer in `Free`; - adds a regression test that verifies limiting the output does not change the input batch row count or vector lengths. Local validation: - `gofmt` - `git diff --check` - focused `TestLimitDoesNotMutateInputBatch` - focused race test with `-count=100` - full `pkg/sql/colexec/limit` race suite - `go vet ./pkg/sql/colexec/limit` - BVT was not run locally. Approved by: @XuPeng-SH
`LIMIT` truncated its input batch in place. Recursive CTE pipelines can fan out the same batch to multiple consumers, so one consumer could shorten the vectors while another consumer still observed the original row count. This caused downstream expression evaluation to access rows beyond the shortened vector and panic. This change: - copies the final truncated batch into a buffer owned by the `Limit` operator; - keeps the shared upstream batch immutable; - releases the owned buffer in `Free`; - adds a regression test that verifies limiting the output does not change the input batch row count or vector lengths. Local validation: - `gofmt` - `git diff --check` - focused `TestLimitDoesNotMutateInputBatch` - focused race test with `-count=100` - full `pkg/sql/colexec/limit` race suite - `go vet ./pkg/sql/colexec/limit` - BVT was not run locally. Approved by: @XuPeng-SH
`LIMIT` truncated its input batch in place. Recursive CTE pipelines can fan out the same batch to multiple consumers, so one consumer could shorten the vectors while another consumer still observed the original row count. This caused downstream expression evaluation to access rows beyond the shortened vector and panic. This change: - copies the final truncated batch into a buffer owned by the `Limit` operator; - keeps the shared upstream batch immutable; - releases the owned buffer in `Free`; - adds a regression test that verifies limiting the output does not change the input batch row count or vector lengths. Local validation: - `gofmt` - `git diff --check` - focused `TestLimitDoesNotMutateInputBatch` - focused race test with `-count=100` - full `pkg/sql/colexec/limit` race suite - `go vet ./pkg/sql/colexec/limit` - BVT was not run locally. Approved by: @XuPeng-SH
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #23080
What this PR does / why we need it:
LIMITtruncated its input batch in place. Recursive CTE pipelines can fan out the same batch to multiple consumers, so one consumer could shorten the vectors while another consumer still observed the original row count. This caused downstream expression evaluation to access rows beyond the shortened vector and panic.This change:
Limitoperator;Free;Local validation:
gofmtgit diff --checkTestLimitDoesNotMutateInputBatch-count=100pkg/sql/colexec/limitrace suitego vet ./pkg/sql/colexec/limit