cherrypick-2.0: sql, kv: use Delete instead of DeleteRange to lessen impact on tscache #23289
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, on the slow path for deletion from SQL, rows were deleted
using a call to
DeleteRange
in order to remove all column familieswith a single statement. It turns out this is better done using one
call per column family to
Delete
.DeleteRange
must update thewrite timestamp cache in order to avoid lost update anomalies. By
lessening the pressure on the timestamp cache, we can avoid pushing
a transaction's commit timestamp forward and triggering a retry. This
allow substantially longer / larger
DELETE FROM
statements to runto completion, assuming there is no other concurrency which will force
a retry.
In conjunction, a realization from #21165 was that large
DELETE FROM
statements can end up running forever. This occurs because they are
retryable from the SQL executor and continue to get retryable errors
due to the timestamp cache being unable to avoid pushing their
timestamps forward.
Release note (sql change): will fix endless churn experienced from
large
DELETE FROM
statements, either by allowing them to complete,or by exiting with an error message indicating the transaction is too
large to complete.