-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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-20.1: physicalplan: preevaluate subqueries on LocalExprs and always set LocalExprs #56267
Conversation
When the plan is local, we do not serialize expressions. Previously, in such a case we would also not preevaluate the subqueries in the expressions which made `EXPLAIN (VEC)` return unexpected plan (there would `tree.Subquery` in the expression which we don't support in the vectorized, so we would wrap the plan). Now we will preevalute the subqueries before storing in the processor spec. AFAICT it affects only this explain variant and nothing else. Release note: None
Previously, we would set either `LocalExpr` (unserialized expression, only we have the full plan on a single node) or `Expr` (serialized expression, when we have distributed plan as well as in some tests). However, we could be setting both and making best effort to reuse unserialized `LocalExpr` on the gateway even if the plan is distributed. And this commit adds such behavior. Release note: None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also add a regression test with the repro (possibly as a separate PR against master that is backported both to 20.2 and 20.1).
Reviewed 1 of 1 files at r1, 6 of 6 files at r2.
Reviewable status: complete! 1 of 0 LGTMs obtained
@yuzefovich i agree, i will make a regression test. for this backport, do you know if this change is expected? a query from and do you know more about this failure?
|
The change on I also now think that we need to backport the second commit from the original PR - without it, it is possible for us to get into a situation when |
thanks @yuzefovich i tried the backport but i don't feel confident that i can do it correctly. can you please take it over? i'll still write the regression test |
Sounds good, I'll work on the backport and debug the issue to see why the PR fixed it. |
Hm, actually backporting the whole PR doesn't fix the issue - I can still repro the problem with all 3 commits cherry-picked. I've been debugging the issue for a bit, and the root cause of the issue is that we're using
Since these issues fall under the SQL Experience team, @rafiss I'd like for you to take over fixing the problem. I'm guessing that there were other changes in 20.2 branch that together with #49891 happen to go around the problem, and I have a feeling that it actually might be still lurking on the master branch. |
Thanks for your detailed investigation! I can own the fix again. Sorry for sending you down a rabbit hole with this backport. I hope I didn't mess up the git bisect... |
Though to clarify, the error |
Does the issue actually cause a panic in some cases? My understanding is that it'll always be an internal error with the stacktrace printed out (and a sentry report on release binaries), but the node doesn't actually crash. |
Yeah it can cause a panic, at least according to the support ticket. So far I have only seen an internal error actually. I will create a public issue to track this and document further progress/reproduction steps there. #56335 |
I tested this backport locally and it does fix the issue. |
Ah I see, it fails with |
Backport 2/3 commits from #49891.
/cc @cockroachdb/release
I am backporting because it also fixes an error caused when performing comparison between collated strings.
physicalplan: preevaluate subqueries on LocalExprs
When the plan is local, we do not serialize expressions. Previously, in
such a case we would also not preevaluate the subqueries in the
expressions which made
EXPLAIN (VEC)
return unexpected plan (therewould
tree.Subquery
in the expression which we don't support in thevectorized, so we would wrap the plan). Now we will preevalute the
subqueries before storing in the processor spec. AFAICT it affects only
this explain variant and nothing else.
Release note: None
physicalplan: always store LocalExpr
Previously, we would set either
LocalExpr
(unserialized expression,only when we have the full plan on a single node) or
Expr
(serializedexpression, when we have distributed plan as well as in some tests).
However, we could be setting both and making best effort to reuse
unserialized
LocalExpr
on the gateway even if the plan is distributed.And this commit adds such behavior.
Fixes: #49810.
Release note: None