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

sql: fix panic with UNION ALL #25747

Merged
merged 1 commit into from
May 21, 2018
Merged

Conversation

jordanlewis
Copy link
Member

Previously, UNION ALL distsql plans could panic the server if the two
sub plans had different post processing. Now, this condition is
detected, and a no-op stage is inserted after the plans if necessary.

Fixes #25611.

Release note (bug fix): fix a server crash when trying to plan
certain UNION ALL queries.

@jordanlewis jordanlewis requested review from RaduBerinde and a team May 21, 2018 03:24
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@asubiotto
Copy link
Contributor

Review status: 0 of 3 files reviewed at latest revision, all discussions resolved.


pkg/sql/distsqlplan/physical_plan.go, line 263 at r1 (raw file):

// CheckConsistentPost returns a non-nil error if not all of the processors of
// the last stage of the PhysicalPlan have identical post-processing.
func (p *PhysicalPlan) CheckConsistentPost() error {

I find this comment a bit confusing. You might consider rephrasing to something like:

CheckConsistentPost checks that the processors of the last stage of the PhysicalPlan have identical post-processing, returning an error if not.

Also, since this checks the latest stage of a physical plan, it might make sense to call this CheckLastStagePost.


Comments from Reviewable

@RaduBerinde
Copy link
Member

:lgtm:

Maybe we should add a call to GetLastStagePost in createPlanForNode (after the switch), perhaps behind the TestRace flag? I would at least try to add it temporarily and run all the logictests to see if it discovers other cases.


Review status: 0 of 3 files reviewed at latest revision, 1 unresolved discussion.


pkg/sql/logictest/testdata/logic_test/union, line 260 at r1 (raw file):


query I
SELECT a FROM a WHERE a > 2 UNION ALL (select a from c WHERE b > 2) limit 1;

[nit] SELECT FROM LIMIT


Comments from Reviewable

Previously, UNION ALL distsql plans could panic the server if the two
sub plans had different post processing. Now, this condition is
detected, and a no-op stage is inserted after the plans if necessary.

Release note (bug fix): fix a server crash when trying to plan
certain UNION ALL queries.
@jordanlewis
Copy link
Member Author

I did it temporarily, saw tests pass, and then added it to the guard behind the metadata check planning where it can live on forever.


Review status: 0 of 3 files reviewed at latest revision, 2 unresolved discussions.


pkg/sql/distsqlplan/physical_plan.go, line 263 at r1 (raw file):

Previously, asubiotto (Alfonso Subiotto Marqués) wrote…

I find this comment a bit confusing. You might consider rephrasing to something like:

CheckConsistentPost checks that the processors of the last stage of the PhysicalPlan have identical post-processing, returning an error if not.

Also, since this checks the latest stage of a physical plan, it might make sense to call this CheckLastStagePost.

Done.


pkg/sql/logictest/testdata/logic_test/union, line 260 at r1 (raw file):

Previously, RaduBerinde wrote…

[nit] SELECT FROM LIMIT

Done.


Comments from Reviewable

@jordanlewis
Copy link
Member Author

bors r+

craig bot pushed a commit that referenced this pull request May 21, 2018
25747: sql: fix panic with UNION ALL r=jordanlewis a=jordanlewis

Previously, UNION ALL distsql plans could panic the server if the two
sub plans had different post processing. Now, this condition is
detected, and a no-op stage is inserted after the plans if necessary.

Fixes #25611.

Release note (bug fix): fix a server crash when trying to plan
certain UNION ALL queries.

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
@craig
Copy link
Contributor

craig bot commented May 21, 2018

Build succeeded

@craig craig bot merged commit cba219c into cockroachdb:master May 21, 2018
@jordanlewis jordanlewis deleted the union-crash branch May 21, 2018 22:02
craig bot pushed a commit that referenced this pull request Jul 6, 2018
27233: cherrypick-2.0: fix panic with UNION ALL r=asubiotto a=asubiotto

Cherry-pick #25720 and #25747. There was a merge conflict to do with the metadata test receiver, which is not present in 2.0, so that code was removed.

Fixes #27200

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
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.

distsql: "inconsistent post-processing" panic.
4 participants