cockroachdb / cockroachdb/cockroach
kv: consider making the `kv.DB` API transactional
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
Currently, in production, SQL always uses the transactional KV API. The non-transactional `kv.DB` API is often used in tests and internal tools. There are a few reasons to consider making the `kv.DB` API transactional as well:
1. It currently fails to set admission headers: https://github.com/cockroachdb/cockroach/issues/79212.
2. Non-transactional requests are treated as idempotent in the `DistSender`, and it's possible that they get double-evaluated. This is somewhat documented in the comment below, but not widely understood by engineering teams that use the API.
https://github.com/cockroachdb/cockroach/blob/30c0ad2fc84cae90ed708f988f93e2c1ece271e3/pkg/kv/kvclient/kvcoord/dist_sender.go#L2860-L2864
We can either remove the `kv.DB` completely (which will require a lot of internal and test changes) or wrap each `db.Run` with a transaction.
Jira issue: CRDB-54910
Contributor guide
Assessment
This issue has not been assessed yet.