Skip to content

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

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
ajwerner:ajwerner/fix-rel-race
Sep 26, 2022
Merged

schemachanger/rel: fix race due to failure to clone constraint slots#88670
craig[bot] merged 1 commit intocockroachdb:masterfrom
ajwerner:ajwerner/fix-rel-race

Conversation

@ajwerner
Copy link
Copy Markdown
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

@ajwerner ajwerner requested a review from a team September 24, 2022 21:13
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@ajwerner ajwerner force-pushed the ajwerner/fix-rel-race branch from ac66c97 to 11adfa6 Compare September 26, 2022 00:56
@ajwerner
Copy link
Copy Markdown
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 ajwerner force-pushed the ajwerner/fix-rel-race branch from 11adfa6 to 139ad31 Compare September 26, 2022 14:28
@ajwerner
Copy link
Copy Markdown
Contributor Author

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

@ajwerner ajwerner force-pushed the ajwerner/fix-rel-race branch from 139ad31 to f67e80d Compare September 26, 2022 14:29
Copy link
Copy Markdown
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 ajwerner force-pushed the ajwerner/fix-rel-race branch from f67e80d to eb01e91 Compare September 26, 2022 15:28
@ajwerner
Copy link
Copy Markdown
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 ajwerner force-pushed the ajwerner/fix-rel-race branch from eb01e91 to 8126b7e Compare September 26, 2022 19:26
@ajwerner
Copy link
Copy Markdown
Contributor Author

bors r+

@craig
Copy link
Copy Markdown
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
Copy Markdown

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