Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kvstreamer: fix the usage of the range iterator #94031

Merged
merged 1 commit into from
Dec 21, 2022

Conversation

yuzefovich
Copy link
Member

@yuzefovich yuzefovich commented Dec 21, 2022

Previously, after Seeking the range iterator to the next key in the batch of requests in the streamer we forgot to check the validity of the iterator. In particular, this could lead to a crash of the process if Seek encountered an error for whatever reason. In practice, I've only observed this when running TPCH with high concurrency when GOMEMLIMIT is set.

The bug was introduced in an innocently-looking refactor in 041b104.

Epic: None

Release note (bug fix): CockroachDB could previously crash in rare circumstances when evaluating lookup and index joins. The bug is present since 22.2.0 release. Temporary workaround without upgrading to the release with this fix is changing the value of undocumented cluster setting sql.distsql.use_streamer.enabled to false.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: Is there a way we can enforce the error check?

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @michae2)

@yuzefovich yuzefovich force-pushed the fix-streamer branch 2 times, most recently from 6240542 to 5fabb7c Compare December 21, 2022 04:46
Copy link
Member Author

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could change RangeIterator interface so that Seek would explicitly return an error instead of invalidating the iterator. However, that would change pretty-nice looking interface where it can be used with the for loop. I looked over how other callers do it, and the streamer is the only one that had an issue and was deviating from the iterator pattern around the for loop, so I just pushed a minor update to bring it more in line with others. PTAL.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @michae2)

Copy link
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: Looks good!

Reviewed all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @michae2 and @yuzefovich)


pkg/kv/kvclient/kvstreamer/streamer.go line 635 at r2 (raw file):

			// This was the last range. Breaking here rather than Seek'ing the
			// iterator to RKeyMax (and, thus, invalidating it) allows us to
			// avoid adding a confusingly-looking message into the trace.

[nit] confusingly-looking -> confusing

Previously, after `Seek`ing the range iterator to the next key in the
batch of requests in the streamer we forgot to check the validity of the
iterator. In particular, this could lead to a crash of the process if
`Seek` encountered an error for whatever reason. In practice, I've only
observed this when running TPCH with high concurrency when GOMEMLIMIT is
set.

The bug was introduced in an innocently-looking refactor in
041b104.

Epic: None

Release note (bug fix): CockroachDB could previously crash in rare
circumstances when evaluating lookup and index joins. The bug is present
since 22.2.0 release. Temporary workaround without upgrading to the
release with this fix is changing the value of undocumented cluster
setting `sql.distsql.use_streamer.enabled` to `false`.
Copy link
Member Author

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TFTR!

bors r+

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @DrewKimball and @michae2)


pkg/kv/kvclient/kvstreamer/streamer.go line 635 at r2 (raw file):

Previously, DrewKimball (Drew Kimball) wrote…

[nit] confusingly-looking -> confusing

Done.

@craig
Copy link
Contributor

craig bot commented Dec 21, 2022

Build succeeded:

@craig craig bot merged commit 8d3a94e into cockroachdb:master Dec 21, 2022
@yuzefovich yuzefovich deleted the fix-streamer branch December 21, 2022 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants