release-22.2: sql: fix recently introduced bug around the internal rowsIterator #103522
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 2/2 commits from #103514.
/cc @cockroachdb/release
This commit fixes a minor bug introduced in c7eb1bf
that could lead to a nil pointer panic. In particular, that commit
introduced
HasResults
method to therowsIterator
, and it assumedthat
first
field is always non-nil when the iterator was returned onQueryIteratorEx
call. However, that is not true - in case an error wasreturned from the connExecutor goroutine, then
rowsIterator.lastErr
isset while
first
is left nil. The expectation is that in such a casethe user of the iterator will receive that error either on
Next
orClose
call, properly cleaning up the iterator. We might want torethink this and return the error explicitly, but in the spirit of
making the least amount of changes, this commit simply added the non-nil
check for the
first
field.Fixes: #103508.
Release note (bug fix): CockroachDB could previously encounter a nil
pointer crash when populating data for SQL Activity page in some rare
cases, and this is now fixed. The bug is present in 22.2.9 and 23.1.1
releases.
Release justification: bug fix.