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 pagination in UPSERT #51608

Merged
merged 2 commits into from
Jul 20, 2020
Merged

sql: fix pagination in UPSERT #51608

merged 2 commits into from
Jul 20, 2020

Conversation

yuzefovich
Copy link
Member

@yuzefovich yuzefovich commented Jul 20, 2020

sql: minor cleanup around upsert

This commit removes a couple of duplicated "init" calls as well as some
unused parameters around upsert code.

Release note: None

sql: fix pagination in UPSERT

optTableUpserter was incorrectly overriding curBatchSize method by
returning insertRows.Len, but that container is not actually used
anywhere. As a result, curBatchSize was always considered 0, and we
didn't perform the pagination on the UPSERTs. The bug was introduced in
#33339 (in 19.1.0).

Fixes: #51391.

Release note (bug fix): Previously, CockroachDB could hit a "command is
too large" error when performing UPSERT operation with many values.
Internally, we attempt to perform such operation by splitting it into
"batches", but the batching mechanism was broken.

@yuzefovich yuzefovich requested review from nvanbenschoten, RaduBerinde and a team July 20, 2020 17:03
@cockroach-teamcity
Copy link
Member

This change is Reviewable

This commit removes a couple of duplicated "init" calls as well as some
unused parameters around upsert code.

Release note: None
`optTableUpserter` was incorrectly overriding `curBatchSize` method by
returning `insertRows.Len`, but that container is not actually used
anywhere. As a result, `curBatchSize` was always considered 0, and we
didn't perform the pagination on the UPSERTs. The bug was introduced in
33339 (in 19.1.0).

Release note (bug fix): Previously, CockroachDB could hit a "command is
too large" error when performing UPSERT operation with many values.
Internally, we attempt to perform such operation by splitting it into
"batches", but the batching mechanism was broken.
Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

:lgtm: Wow, nice find!

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

@yuzefovich
Copy link
Member Author

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Jul 20, 2020

Build succeeded

@craig craig bot merged commit 15574aa into cockroachdb:master Jul 20, 2020
@yuzefovich yuzefovich deleted the upsert branch July 20, 2020 23:02
yuzefovich added a commit to yuzefovich/cockroach that referenced this pull request Sep 16, 2020
In cockroachdb#51608 we fixed a bug with pagination of UPSERTs (now it is possible
to have multiple batches when performing an UPSERT of over 10k rows),
and it exposed another bug in how we're handling an UPSERT with
RETURNING clause - we were clearing the row container too early which
would result in an index of bounds crash. This is now fixed.

Release note (bug fix): Starting from v20.2.0-alpha.3 CockroachDB would
crash when performing an UPSERT with RETURNING clause of more than 10k
rows, and this is now fixed.
yuzefovich added a commit to yuzefovich/cockroach that referenced this pull request Sep 16, 2020
In cockroachdb#51608 we fixed a bug with pagination of UPSERTs (now it is possible
to have multiple batches when performing an UPSERT of over 10k rows),
and it exposed another bug in how we're handling an UPSERT with
RETURNING clause - we were clearing the row container too early which
would result in an index of bounds crash. This is now fixed.

Release note (bug fix): Starting from v20.2.0-alpha.3 CockroachDB would
crash when performing an UPSERT with RETURNING clause of more than 10k
rows, and this is now fixed.
craig bot pushed a commit that referenced this pull request Sep 16, 2020
54420: delegate: implement SHOW GRANTS ON SCHEMA r=arulajmani a=otan

Resolves #53570 

Release note (sql change): Implement `SHOW GRANTS ON SCHEMA
<schema_list>`

54478: sql: fix large UPSERTs with RETURNING r=yuzefovich a=yuzefovich

In #51608 we fixed a bug with pagination of UPSERTs (now it is possible
to have multiple batches when performing an UPSERT of over 10k rows),
and it exposed another bug in how we're handling an UPSERT with
RETURNING clause - we were clearing the row container too early which
would result in an index of bounds crash. This is now fixed.

Fixes: #54465.

Release note (bug fix): Starting from v20.2.0-alpha.3 CockroachDB would
crash when performing an UPSERT with RETURNING clause of more than 10k
rows, and this is now fixed.

Co-authored-by: Oliver Tan <[email protected]>
Co-authored-by: Yahor Yuzefovich <[email protected]>
yuzefovich added a commit to yuzefovich/cockroach that referenced this pull request Sep 17, 2020
In cockroachdb#51608 we fixed a bug with pagination of UPSERTs (now it is possible
to have multiple batches when performing an UPSERT of over 10k rows),
and it exposed another bug in how we're handling an UPSERT with
RETURNING clause - we were clearing the row container too early which
would result in an index of bounds crash. This is now fixed.

Release note (bug fix): Starting from v20.2.0-alpha.3 CockroachDB would
crash when performing an UPSERT with RETURNING clause of more than 10k
rows, and this is now fixed.
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.

Large upserts can hit up against kv.raft.command.max_size
3 participants