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

opt: fix execbuilder output column count for lookup joins #40669

Merged
merged 1 commit into from
Sep 11, 2019

Conversation

rytaft
Copy link
Collaborator

@rytaft rytaft commented Sep 11, 2019

This commit fixes a bug in the execbuilder, which was determining
the number of output columns incorrectly for lookup joins. In particular,
if the join was a semi- or anti-join, the execbuilder was incorrectly
including the right side columns in the column count. This commit
fixes the code so it only includes left side columns for semi- and
anti-joins.

This commit also fixes a bug in the DistSQL planner that was masked
by the bug in the execbuilder. In particular, the output types slice
for lookup semi- and anti-joins incorrectly included the types from the
right side columns. This commit fixes it to only include types for the
left side columns.

Fixes #40562

Release note (bug fix): Fixed an error that could occur when the
optimizer created a plan with a lookup semi- or anti-join nested
inside of another join.

@rytaft rytaft requested a review from a team as a code owner September 11, 2019 13:50
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@justinj justinj left a comment

Choose a reason for hiding this comment

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

:lgtm:! I'm surprised this didn't show up more often

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

@jordanlewis
Copy link
Member

Thanks for the quick fix! I had added this to the release blockers list, so please check the box marking it as done when this merges.

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

Nice find!

@RaduBerinde
Copy link
Member

Regarding merging justification during release stability period, I believe this falls under "Low risk, high benefit changes to existing functionality".

This commit fixes a bug in the execbuilder, which was determining
the number of output columns incorrectly for lookup joins. In particular,
if the join was a semi- or anti-join, the execbuilder was incorrectly
including the right side columns in the column count. This commit
fixes the code so it only includes left side columns for semi- and
anti-joins.

This commit also fixes a bug in the DistSQL planner that was masked
by the bug in the execbuilder. In particular, the output types slice
for lookup semi- and anti-joins incorrectly included the types from the
right side columns. This commit fixes it to only include types for the
left side columns.

Fixes cockroachdb#40562

Release note (bug fix): Fixed an error that could occur when the
optimizer created a plan with a lookup semi- or anti-join nested
inside of another join.
@rytaft
Copy link
Collaborator Author

rytaft commented Sep 11, 2019

TFTR!

Turns out there was another bug lurking in the DistSQL planning side that was masked by this bug. @jordanlewis can you please take a look?

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

DistSQL fix LGTM.

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

Copy link
Member

@jordanlewis jordanlewis left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Collaborator Author

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

Thanks!

bors r+

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

craig bot pushed a commit that referenced this pull request Sep 11, 2019
40583: sqlmigrations: remove ensureMaxPrivileges migration r=mberhault a=ajwerner

This migration has baked. Furthermore it uses table descriptors in ways I'm
working to change and I want to see it gone.

Release note: None

40669: opt: fix execbuilder output column count for lookup joins r=rytaft a=rytaft

This commit fixes a bug in the `execbuilder`, which was determining
the number of output columns incorrectly for lookup joins. In particular,
if the join was a semi- or anti-join, the `execbuilder` was incorrectly
including the right side columns in the column count. This commit
fixes the code so it only includes left side columns for semi- and
anti-joins.

This commit also fixes a bug in the DistSQL planner that was masked
by the bug in the `execbuilder`. In particular, the output types slice
for lookup semi- and anti-joins incorrectly included the types from the
right side columns. This commit fixes it to only include types for the
left side columns.

Fixes #40562

Release note (bug fix): Fixed an error that could occur when the
optimizer created a plan with a lookup semi- or anti-join nested
inside of another join.

Co-authored-by: Andrew Werner <ajwerner@cockroachlabs.com>
Co-authored-by: Rebecca Taft <becca@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Sep 11, 2019

Build succeeded

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: a crash with a lookup join
5 participants