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

exec: fix a panic with sum_int aggregate with input types other than Int64 #38941

Merged
merged 2 commits into from
Jul 17, 2019

Conversation

yuzefovich
Copy link
Member

@yuzefovich yuzefovich commented Jul 17, 2019

First commit wraps Next of materializer with a vectorized panic catcher.

We used to catch panics only when calling Next() on the the input to
materializer. However, it is also possible that types get messed up
during planning a vectorized flow which can lead to a type conversion
panic. We do not want to crash in such case either, so we wrap full
Next() method with a catcher.

Second commit falls back to DistSQL on sum_int if not on Int64.

Currently, our aggregates expect that input and output types are
the same. However, sum_int is planned such that flow consumer
expects Int64 regardless of the input types. Supporting this would
require adding specialized sum aggregates that would take in any
int type and would output Int64. It is easier for now to just
fallback to DistSQL on non-int64 input types.

Fixes: #38937.

@yuzefovich yuzefovich requested review from jordanlewis, asubiotto and a team July 17, 2019 20:00
@cockroach-teamcity
Copy link
Member

This change is Reviewable

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.

Reviewed 1 of 1 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @asubiotto, @jordanlewis, and @yuzefovich)


pkg/sql/distsqlrun/materializer.go, line 188 at r1 (raw file):

		// It is possible that types were messed up during planning, so we want to
		// catch type conversion panic if it occurs.
		if err := exec.CatchVectorizedRuntimeError(populateOutputRow); err != nil {

We now have 2 calls to the catcher in this function. Can we hoist it outside? Since the catcher ignores stuff that we didn't generate, it should be safe.

Copy link
Member Author

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

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


pkg/sql/distsqlrun/materializer.go, line 188 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

We now have 2 calls to the catcher in this function. Can we hoist it outside? Since the catcher ignores stuff that we didn't generate, it should be safe.

I agree, it should be safe. Done.

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.

:lgtm:

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

@yuzefovich
Copy link
Member Author

TFTRs!

bors r+

@craig
Copy link
Contributor

craig bot commented Jul 17, 2019

Merge conflict

@yuzefovich
Copy link
Member Author

bors r-

We used to catch panics only when calling Next() on the the input to
materializer. However, it is also possible that types get messed up
during planning a vectorized flow which can lead to a type conversion
panic. We do not want to crash in such case either, so we wrap full
Next() method with a catcher.

Release note: None
Currently, our aggregates expect that input and output types are
the same. However, sum_int is planned such that flow consumer
expects Int64 regardless of the input types. Supporting this would
require adding specialized sum aggregates that would take in any
int type and would output Int64. It is easier for now to just
fallback to DistSQL on non-int64 input types.

Release note: None
@yuzefovich
Copy link
Member Author

bors r+

craig bot pushed a commit that referenced this pull request Jul 17, 2019
38941: exec: fix a panic with sum_int aggregate with input types other than Int64 r=yuzefovich a=yuzefovich

First commit wraps Next of materializer with a vectorized panic catcher.

We used to catch panics only when calling Next() on the the input to
materializer. However, it is also possible that types get messed up
during planning a vectorized flow which can lead to a type conversion
panic. We do not want to crash in such case either, so we wrap full
Next() method with a catcher.

Second commit falls back to DistSQL on sum_int if not on Int64.

Currently, our aggregates expect that input and output types are
the same. However, sum_int is planned such that flow consumer
expects Int64 regardless of the input types. Supporting this would
require adding specialized sum aggregates that would take in any
int type and would output Int64. It is easier for now to just
fallback to DistSQL on non-int64 input types.

Fixes: #38937.

Co-authored-by: Yahor Yuzefovich <yahor@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Jul 17, 2019

Build succeeded

@craig craig bot merged commit 99b37e4 into cockroachdb:master Jul 17, 2019
@yuzefovich yuzefovich deleted the exec-panic branch July 19, 2019 03:56
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: panic: interface conversion: coldata.column is []int16, not []int64
4 participants