-
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
sql: make transaction_rows_{read|written}_err and large_full_scan_rows guardrails halt query execution #70473
Comments
@rytaft @jordanlewis We should revisit this issue. The motivation of these guardrails would be to protect the cluster before destabilization. |
This is likely a non-trivial amount of work. We need to see if it's needed. @vy-ton |
Note for posterity: when fixing this, we might be able to take advantage of whatever mechanism is used for transaction timeouts (though there will be more to this fix than just invoking that mechanism). |
When we fix this, it would be nice to use the same technique to make a full scan halt immediately if it reads more than |
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.
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.
104290: sql: make transaction_rows_read_err prevent large scans r=rytaft a=rytaft 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 #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. 104337: sql: fix reset_sql_stats to truncate activity tables r=j82w a=j82w Previously: The reset stats on the ui and crdb_internal.reset_sql_stats() would only reset the statement_statistics and transaction_statics tables. This would leave the sql_activity table with old data. The reset stats now truncates the sql_activity table as well. Fixes: #104321 Epic: none Release note (sql change): Fix crdb_internal.reset_sql_stats() to cleanup the sql_activity table which work as a cache for the stats. Co-authored-by: Rebecca Taft <[email protected]> Co-authored-by: j82w <[email protected]>
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.
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.
We recently added guardrails to limit the number of rows read or written by a single transaction. A transaction reading more than
transaction_rows_read_err
rows (or writing more thantransaction_rows_written_err
rows) now fails with an error.To simplify implementation, we chose to emit this error after the violating query has already finished executing and delivered results to the application. This is still quite useful: well-behaved applications will see the error, and the transaction will be aborted. But there is a risk that poorly written applications might not see the error after receiving results of a read-only autocommit query. There is also a risk that the violating query will have already hurt cluster performance before hitting the guardrail.
It would be more defensive for the current query execution to halt immediately upon violating one of these limits.
Here's an example:
Jira issue: CRDB-10088
The text was updated successfully, but these errors were encountered: