Skip to content

opt: fix rare incorrect results due to sort between paired joins#92632

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
DrewKimball:paired-joins
Nov 30, 2022
Merged

opt: fix rare incorrect results due to sort between paired joins#92632
craig[bot] merged 1 commit intocockroachdb:masterfrom
DrewKimball:paired-joins

Conversation

@DrewKimball
Copy link
Copy Markdown
Collaborator

Previously, it was possible for paired joins to produce incorrect results in the case when an ordering was required of their output, and a sort was added between the paired joins to enforce the ordering.

This patch prevents a sort from being added to the output of the first join in a set of paired joins. This is necessary because the continuation column that is used to indicate false positives matched by the first join relies on the ordering being maintained between the joins.

Fixes #89603

Release note: None

@DrewKimball DrewKimball requested review from msirek and rytaft November 29, 2022 00:11
@DrewKimball DrewKimball requested a review from a team as a code owner November 29, 2022 00:11
Copy link
Copy Markdown
Contributor

@msirek msirek left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this! It is much simpler and more straightforward than #89840. I will close that PR.
LGTM

@DrewKimball
Copy link
Copy Markdown
Collaborator Author

TFTR! Yeah, it helped to talk things through as a pair-programming project. Still might be ideal to make it a single operator or something, but this seems like the easiest fix considering it's probably a pretty rare bug.

The test failures are the same as #92536, so unrelated.

Copy link
Copy Markdown
Collaborator

@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.

LGTM thanks!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: that to handle -> to handle
nit: enforcing a sort -> adding a sort (or enforcing an ordering)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@rytaft
Copy link
Copy Markdown
Collaborator

rytaft commented Nov 29, 2022

Consider also adding a backport label for 22.2 and 22.1

Copy link
Copy Markdown
Collaborator

@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.

LGTM

Copy link
Copy Markdown
Contributor

@mgartner mgartner left a comment

Choose a reason for hiding this comment

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

Very nice! LGTM

Previously, it was possible for paired joins to produce incorrect results
in the case when an ordering was required of their output, and a sort was
added between the paired joins to enforce the ordering.

This patch prevents a sort from being added to the output of the first
join in a set of paired joins. This is necessary because the continuation
column that is used to indicate false positives matched by the first join
relies on the ordering being maintained between the joins.

Fixes cockroachdb#89603

Release note: None
@DrewKimball
Copy link
Copy Markdown
Collaborator Author

TFTRs!

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@DrewKimball
Copy link
Copy Markdown
Collaborator Author

The linter failure is a known issue.

bors r+

@craig craig bot merged commit 21ec411 into cockroachdb:master Nov 30, 2022
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Nov 30, 2022

Build succeeded:

@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Nov 30, 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 7cfcce1 to blathers/backport-release-22.1-92632: 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 7cfcce1 to blathers/backport-release-22.2-92632: 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: incorrect results due to sort in-between paired joins

5 participants