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 UPSERT fast path regression #13488
Conversation
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.
LGTM
pkg/sql/tablewriter.go
Outdated
tu.evaler != nil && tu.evaler.isIdentityEvaler() | ||
tu.evaler != nil && tu.evaler.isIdentityEvaler() && | ||
// Disable the upsert fast path when columns or indexes are being added | ||
// or dropped. |
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.
This is mildly unfortunate as the fast-path is ~2x faster than the slow-path. So adding a column will cause performance to temporarily drop in half? Is there any hope to fix this eventually? Perhaps file an issue.
pkg/sql/upsert_test.go
Outdated
filter := func(filterArgs storagebase.FilterArgs) *roachpb.Error { | ||
if filterArgs.Req.Method() == roachpb.Scan && | ||
bytes.Compare(filterArgs.Req.Header().Key, keys.UserTableDataMin) >= 0 { | ||
scans++ |
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.
I'm mildly surprised this doesn't need to be done atomically.
Review status: 0 of 4 files reviewed at latest revision, 2 unresolved discussions. pkg/sql/tablewriter.go, line 231 at r1 (raw file): Previously, petermattis (Peter Mattis) wrote…
IIRC, when you're adding a column, you can't set it as a user while the schema change is being run. Which I think makes it impossible to fast path during that time pkg/sql/upsert_test.go, line 42 at r1 (raw file): Previously, petermattis (Peter Mattis) wrote…
Same. atomic'd it Comments from Reviewable |
Review status: 0 of 4 files reviewed at latest revision, 1 unresolved discussion, all commit checks successful. pkg/sql/tablewriter.go, line 231 at r1 (raw file): Previously, danhhz (Daniel Harrison) wrote…
Ok, thinking about it more this makes sense, but shouldn't the conditional be part of the next line. What do mutations have to do with
Comments from Reviewable |
Reviewed 3 of 4 files at r1, 1 of 1 files at r2. pkg/sql/upsert_test.go, line 43 at r2 (raw file):
That's a very clever approach to testing this. TIL! Comments from Reviewable |
Review status: all files reviewed at latest revision, 1 unresolved discussion, all commit checks successful. pkg/sql/upsert_test.go, line 43 at r2 (raw file): Previously, knz (kena) wrote…
Yes, I can probably enhance this to verify that we have a 1PC transaction. See #13500. Comments from Reviewable |
And add a test to prevent future regressions. A second bug was unearthed which caused the upsert fast path to be incorrect during schema changes. This was caught by the schema change tests when the regression was fixed. Closes cockroachdb#13437.
Thanks for the reviews! Review status: 3 of 4 files reviewed at latest revision, 2 unresolved discussions. pkg/sql/tablewriter.go, line 231 at r1 (raw file): Previously, petermattis (Peter Mattis) wrote…
I was thinking of when the mutation is a column, then it can't be specified as the identity expr by the user. But you're right that indexes don't fall into this. Moved. I also improved this comment a bit Comments from Reviewable |
And add a test to prevent future regressions.
A second bug was unearthed which caused the upsert fast path to be
incorrect during schema changes. This was caught by the schema change
tests when the regression was fixed.
Closes #13437.
cc @petermattis
This change is