pingcap / pingcap/tidb

Improve GCWorker.resolveLocksForRange()

Open
#32,627 0 comments 0 reactions 0 assignees View on GitHub
sig/transaction type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement

The resolve-lock test meets this error.
```
[2022/02/23 02:49:24.283 +00:00] [INFO] [lock_resolver.go:257] ["BatchResolveLocks: lookup txn status"] ["cost time"=21.235119448s] ["num of txn"=199]
...
[2022/02/23 02:52:17.284 +00:00] [INFO] [lock_resolver.go:257] ["BatchResolveLocks: lookup txn status"] ["cost time"=226.066µs] ["num of txn"=199]
[2022/02/23 02:52:20.665 +00:00] [INFO] [lock_resolver.go:257] ["BatchResolveLocks: lookup txn status"] ["cost time"=272.354µs] ["num of txn"=199]
[2022/02/23 02:52:23.417 +00:00] [INFO] [lock_resolver.go:257] ["BatchResolveLocks: lookup txn status"] ["cost time"=125.983µs] ["num of txn"=199]
[2022/02/23 02:52:26.330 +00:00] [INFO] [lock_resolver.go:257] ["BatchResolveLocks: lookup txn status"] ["cost time"=145.135µs] ["num of txn"=199]
[2022/02/23 02:52:26.331 +00:00] [WARN] [backoff.go:154] ["regionMiss backoffer.maxSleep 200000ms is exceeded, errors:\nremain locks: 995 at 2022-02-23T02:52:21.168127888Z\nepoch_not_match:<> at 2022-02-23T02:52:23.436051982Z\nremain locks: 995 at 2022-02-23T02:52:23.936925959Z\nlongest sleep type: txnLock, time: 143916ms"]
[2022/02/23 02:52:26.331 +00:00] [INFO] [range_task.go:310] ["canceling range task because of error"] [name=resolve-locks-runner] [startKey=] [endKey=] [error="resolve lock timeout"]
[2022/02/23 02:52:26.331 +00:00] [INFO] [range_task.go:233] ["range task failed"] [name=resolve-locks-runner] [startKey=] [endKey=] ["cost time"=4m20.364688408s] [error="resolve lock timeout"]
[2022/02/23 02:52:26.332 +00:00] [ERROR] [gc_worker.go:1050] ["[gc worker] resolve locks failed"] [uuid=testGCWorker] [safePoint=431380099491430403] [error="resolve lock timeout"]
```

`LockResolver.BatchResolveLocks()` doesn't retry resolve-lock requests when meets region errors and does backoff
https://github.com/tikv/client-go/blob/df187fa79aa1dedc293a1eae37ef8b3a522dba46/txnkv/txnlock/lock_resolver.go#L282-L288

TiDB backoffs again which is duplicated and needn't use the same backoffer for a single range to resolve locks https://github.com/pingcap/tidb/blob/a680d6638319336cbf52011f632da886e455e14f/store/gcworker/gc_worker.go#L1146.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.