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

release-21.2: opt: do not add invalid casts to match types in set operations #75276

Merged
merged 1 commit into from
Jan 24, 2022

Conversation

blathers-crl[bot]
Copy link

@blathers-crl blathers-crl bot commented Jan 21, 2022

Backport 1/1 commits from #75219 on behalf of @mgartner.

/cc @cockroachdb/release


The optbuilder adds casts in order to match non-identical left/right
types of set operations like UNION (see #60560). This change prevents
the optbuilder from adding casts that are invalid, which caused internal
errors. Now, a user error is thrown if no such cast exists from the left
or right input type to the output type.

Fixes #70831

Release note (bug fix): A bug has been fixed that caused internal errors
in queries with set operations, like UNION, when corresponding columns
on either side of the set operation were not the same. This error only
occurred with a limited set of types. This bug is present in versions
20.2.6+, 21.1.0+, and 21.2.0+.


Release justification: This fixes a rare bug that causes internal errors.

@blathers-crl blathers-crl bot requested a review from a team as a code owner January 21, 2022 16:34
@blathers-crl blathers-crl bot force-pushed the blathers/backport-release-21.2-75219 branch from 13637dc to 0b6ebd8 Compare January 21, 2022 16:34
@blathers-crl blathers-crl bot requested review from RaduBerinde and rafiss January 21, 2022 16:34
@blathers-crl
Copy link
Author

blathers-crl bot commented Jan 21, 2022

Thanks for opening a backport.

Please check the backport criteria before merging:

  • Patches should only be created for serious issues or test-only changes.
  • Patches should not break backwards-compatibility.
  • Patches should change as little code as possible.
  • Patches should not change on-disk formats or node communication protocols.
  • Patches should not add new functionality.
  • Patches must not add, edit, or otherwise modify cluster versions; or add version gates.
If some of the basic criteria cannot be satisfied, ensure that the exceptional criteria are satisfied within.
  • There is a high priority need for the functionality that cannot wait until the next release and is difficult to address in another way.
  • The new functionality is additive-only and only runs for clusters which have specifically “opted in” to it (e.g. by a cluster setting).
  • New code is protected by a conditional check that is trivial to verify and ensures that it only runs for opt-in clusters.
  • The PM and TL on the team that owns the changed code have signed off that the change obeys the above rules.

Add a brief release justification to the body of your PR to justify this backport.

Some other things to consider:

  • What did we do to ensure that a user that doesn’t know & care about this backport, has no idea that it happened?
  • Will this work in a cluster of mixed patch versions? Did we test that?
  • If a user upgrades a patch version, uses this feature, and then downgrades, what happens?

@blathers-crl blathers-crl bot added blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. labels Jan 21, 2022
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@mgartner mgartner force-pushed the blathers/backport-release-21.2-75219 branch 2 times, most recently from 5126078 to 0e26ec9 Compare January 21, 2022 21:52
return left
if _, ok := tree.LookupCastVolatility(src, tgt, nil /* sessionData */); !ok {
// Error if no cast exists from src to tgt.
// TODO(#75103): For legacy reasons, we check for a valid cast in
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think the comment got truncated

Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't have been there in the first place. Removed.

{
// Error.
left: types.MakeArray(types.MakeTuple([]*types.T{types.Bool})),
right: types.MakeArray(types.MakeTuple([]*types.T{types.Bool, types.Int})),
Copy link
Collaborator

Choose a reason for hiding this comment

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

i noticed that this test case differs from the one in #75219 - is that on purpose?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes. In #75219 we're using the OID->OID castMap to determine which casts are valid. In the backports castMap does not yet exist, so we're using the family->family validCasts. They don't match up perfectly so the cast from types.Any -> types.Bool that is not allowed on master is allowed in these release branches, so the test had to change.

The optbuilder adds casts in order to match non-identical left/right
types of set operations like UNION (see #60560). This change prevents
the optbuilder from adding casts that are invalid, which caused internal
errors. Now, a user error is thrown if no such cast exists from the left
or right input type to the output type.

Release note (bug fix): A bug has been fixed that caused internal errors
in queries with set operations, like UNION, when corresponding columns
on either side of the set operation were not the same. This error only
occurred with a limited set of types. This bug is present in versions
20.2.6+, 21.1.0+, and 21.2.0+.
@mgartner mgartner force-pushed the blathers/backport-release-21.2-75219 branch from 0e26ec9 to 91194f1 Compare January 24, 2022 16:14
Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

lgtm!

Reviewed 2 of 3 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @RaduBerinde and @rafiss)

@mgartner mgartner merged commit f479a04 into release-21.2 Jan 24, 2022
@mgartner mgartner deleted the blathers/backport-release-21.2-75219 branch January 24, 2022 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants