-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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-22.2: sql: make transaction_rows_read_err prevent large scans #104368
Conversation
Thanks for opening a backport. Please check the backport criteria before merging:
If some of the basic criteria cannot be satisfied, ensure that the exceptional criteria are satisfied within.
Add a brief release justification to the body of your PR to justify this backport. Some other things to consider:
|
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.
Reviewed 13 of 13 files at r1, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @michae2 and @rytaft)
pkg/sql/opt/exec/execbuilder/testdata/guardrails
line 74 at r1 (raw file):
table: guardrails@guardrails_pkey spans: /1-/11 limit: 2
Something that I wanted to point out on the original PR, then scratched it, and now I think it might be worth mentioning after all. The fact that we added a hard limit makes it so that we disable the parallelism of the scan. For example, in this query without the guardrail we'd be able to parallelize the scan across ranges.
So I'm wondering whether we should mention this caveat in the release note, something like "For some queries in rare cases this change may end up disabling cross-range parallelism of the scan operation which can result in increase of query latency." That said, cases when we can use the parallelism are few, so I'll leave it up to you to decide whether to adjust the release note.
Prior to this commit, setting transaction_rows_read_err to a non-zero value would cause a transaction to fail as soon as a statement caused the total number of rows read to exceed transaction_rows_read_err. However, it was possible that each statement could read many more than transaction_rows_read_err rows. This commit adds logic so that a single scan never reads more than transaction_rows_read_err+1 rows if transaction_rows_read_err is set. Informs cockroachdb#70473 Release note (performance improvement): If transaction_rows_read_err is set to a non-zero value, we now ensure that any single scan never reads more than transaction_rows_read_err+1 rows. This prevents transactions that would error due to the transaction_rows_read_err setting from causing a large performance overhead due to large scans. For some queries in rare cases this change may end up disabling cross-range parallelism of the scan operation which can result in increase of query latency.
a2ed75e
to
5e33383
Compare
Previously, yuzefovich (Yahor Yuzefovich) wrote…
Sure, I already merged the PRs on master and 23.1, though. I'll see if I can figure out how to change the release notes after the fact. |
Backport 1/1 commits from #104290.
/cc @cockroachdb/release
Prior to this commit, setting
transaction_rows_read_err
to a non-zero value would cause a transaction to fail as soon as a statement caused the total number of rows read to exceedtransaction_rows_read_err
. However, it was possible that each statement could read many more thantransaction_rows_read_err
rows. This commit adds logic so that a single scan never reads more thantransaction_rows_read_err+1
rows iftransaction_rows_read_err
is set.Informs #70473
Release note (performance improvement): If
transaction_rows_read_err
is set to a non-zero value, we now ensure that any single scan never reads more thantransaction_rows_read_err+1
rows. This prevents transactions that would error due to thetransaction_rows_read_err
setting from causing a large performance overhead due to large scans. For some queries in rare cases this change may end up disabling cross-range parallelism of the scan operation which can result in increase of query latency.Release justification: low-risk fix to reduce the likelihood of OOMs for customers