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

schemachanger/rel: fix race due to failure to clone constraint slots #88670

Merged
merged 1 commit into from
Sep 26, 2022

Conversation

ajwerner
Copy link
Contributor

The fundamental race here is that while the slots themselves were being copied by value, the "any" clauses which are a slice were not. The second bug here is that the "inline" values were not being properly reset. That bug could lead to problems when the query was run again in the context of a different element set. We need to reset those inline values too.

Fixes #88628

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@ajwerner
Copy link
Contributor Author

In practice this bug was less severe than it sounded -- the values used in these slots are always constants and are never data-dependent constants, so the value we'll fill always ends up being the same unless the query were about structs or strings. We currently never search by strings, but if we did, we would have had a bug. I'm adding some more targeted tests.

@ajwerner
Copy link
Contributor Author

Alrighty, I wrote a better, lower-level test.

Copy link
Collaborator

@fqazi fqazi left a comment

Choose a reason for hiding this comment

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

:lgtm: One minor nit with an incomplete comment

Reviewed 7 of 7 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @ajwerner)


pkg/sql/schemachanger/rel/query_eval.go line 51 at r1 (raw file):

	for i := range clone {
		// If there are any slots which map to a set of allowed values, we need
		// to clone those values because during query evaluation, we'll

The comment is incomplete here?

@ajwerner
Copy link
Contributor Author

TFTR!

The fundamental race here is that while the slots themselves were being copied
by value, the "any" clauses which are a slice were not. The second bug here is
that the "inline" values were not being properly reset. That bug could lead to
problems when the query was run again in the context of a different element
set. We need to reset those inline values too.

Fixes cockroachdb#88628

Release note: None
@ajwerner
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Sep 26, 2022

Build succeeded:

@craig craig bot merged commit c432bd7 into cockroachdb:master Sep 26, 2022
@blathers-crl
Copy link

blathers-crl bot commented Sep 26, 2022

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from 8126b7e to blathers/backport-release-22.1-88670: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.1.x failed. See errors above.


error creating merge commit from 8126b7e to blathers/backport-release-22.2-88670: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.2.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

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.

sql: data race in schema changer / plan visitor
3 participants