cockroachdb / cockroachdb/cockroach
kvclient: Potential incorrect use of READ_UNCOMMITTED in the RangeCache
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Describe the problem**
As part of #91638 the range cache was changed to do 2 separate reads, one against "followers" and one against the "leaseholder". This is a good optimization, however, when reading against the leaseholder, the read is done with `READ_UNCOMMITTED` consistency level. As of the current release, this consistency level does not guarantee that a completed write will be seen immediately. It is better to think of this level as providing eventual consistency. It is unclear if this can be changed without breaking its usage for range merges (the only other usage of this level in our codebase).
See: https://github.com/cockroachdb/cockroach/blob/898a32a13461c55d79c60cfe7d93e97856465957/pkg/kv/kvserver/concurrency/concurrency_manager.go#L383-L385
One of three things should happen:
1) Since it is a "fallback" level, remove the new assertions as they aren't guaranteed to succeed.
2) Change to use `CONSISTENT` level
3) Change the definition of `READ_UNCOMMITTED` to guarantee that it will see intents.
It seems like 2 is the safest, and I don't have a reproduction of this failing, but it seems likely it could occur with the right timing.
Jira issue: CRDB-25620
Contributor guide
Assessment
This issue has not been assessed yet.