cockroachdb / cockroachdb/cockroach
persistedsqlstats: fix deadlocking logic on `TestSQLStatsReadLimitSizeOnLockedTable`
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
After some testing with different scenarios around `TestSQLStatsReadLimitSizeOnLockedTable` we noticed that the test was able to pass even without the use of an AOST clause for the statements size query in the `SucceedsSoon` case. This was unexpected given that the table should be locked with the `SELECT FOR UPDATE` query.
We deduced that the query for statement stats size:
```
SELECT
count(*)
FROM
system.statement_statistics
```
is allowed because the `SELECT FOR UPDATE` query is an _update_, not a _delete_, so the number of rows remains the same.
Changing this query to:
```
SELECT
*
FROM
system.statement_statistics
```
it does deadlock as intended.
The likely fix here is to use a different query to block, like a `DELETE`.
Jira issue: CRDB-30131
Contributor guide
Assessment
This issue has not been assessed yet.