cockroachdb / cockroachdb/cockroach
sql: permit automatic retries even if results have been returned by memoizing and comparing returned data
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
Today, CockroachDB automatically retries explicit transactions that hit serializable retry errors if the transaction hits the error before any results were delivered to the client. The reason that we cannot retry a transaction after results have been delivered to the client is that conversational SQL has no way to "take back" a result - once you send it to the client, you're promising that it's "good data". The only way to take back that data once it's sent is to abort the transaction with an error.
However, there are cases where we can do better: when every statement in the retried transaction returns exactly the same results as it did the first time, before the retry error was returned.
If this retry strategy were implemented, this could help reduce retry errors in some cases. For example, the following sequence causes a retry error today but would not cause a retry if we could transparently retry a transaction and verify that all results were the same:
```
create table t (a int primary key, b int)
insert into t values (1, 2, 3)
txn 1:
select b from t where a = 1
update t set b = 10 where a = 1
txn 2:
select c from t where a = 1
update t set c = 10 where a = 1
```
Jira issue: CRDB-22533
Epic CRDB-22674
Contributor guide
Assessment
This issue has not been assessed yet.