Concurrent usage of Backoffer which seems not designed to be thread-safe
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
The [`Backoffer`](https://github.com/tikv/client-go/blob/4c6b2171b262807c9197bdb58a82d4626fb0495f/config/retry/backoff.go#L59) didn't use mutexes or atomic operations in it to protect its state. Neither is the `Backoff` method read only. This means the `Backoffer` is not designed to be used in concurrent way. However, it looks like it's already concurrently used everywhere. This is possible to lead to unexpected behavior due to data race. Besides, even if it is thread-safe, it's still questionable whether we should reuse the same backoffer when sending concurrent requests.
A list of concurrent usages of `Backoffer` I've found (maybe incomplete for now):
* When coprocessor tasks processed concurrently and meet errors
* client-go transaction layer processing multiple prewirte/commit/pessimistic_lock batches concurrently
Contributor guide
Assessment
This issue has not been assessed yet.