release-22.1: cfetcher: correctly update the limit hint #88421
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport 1/1 commits from #88391.
/cc @cockroachdb/release
In 41fa8b6 (which was supposed to be a "noop" refactor) we introduced a bug which made it so that we no longer update the remaining limit hint correctly. As a result, the cFetcher might no longer respect the limit hint. What makes things worse is the fact that the KV layer still does everything correctly, so when the cFetcher asks for more rows that exceed the limit, the KV layer does a BatchRequest with 10x of the original limit. This is now fixed by correctly updating the limit hint right before emitting the batch.
Addresses: #88382.
Release note (bug fix): CockroachDB no longer fetches unnecessary rows for queries with LIMITs. The bug was introduced in 22.1.7.
Release justification: bug fix.