goroutine leak when test with tikv
Open
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 362
- Forks
- 274
- Avg merge
- 4d 19m
- Merged PRs (30d)
- 12
Description
goleak: Errors on successful test run: found unexpected goroutines:
[Goroutine 4400 in state select, with github.com/tikv/client-go/v2/internal/retry.newBackoffFn.func1 on top of the stack:
goroutine 4400 [select]:
github.com/tikv/client-go/v2/internal/retry.newBackoffFn.func1(0x1fce648, 0xc0000c6010, 0xffffffffffffffff, 0x5)
/home/runner/work/client-go/client-go/internal/retry/config.go:181 +0x452
github.com/tikv/client-go/v2/internal/retry.(*Backoffer).BackoffWithCfgAndMaxSleep(0xc001bee870, 0xc0004a89f0, 0xffffffffffffffff, 0x1f9edc0, 0xc000e1ad20, 0xc000d94ea8, 0x4103f8)
/home/runner/work/client-go/client-go/internal/retry/backoff.go:170 +0x9f3
github.com/tikv/client-go/v2/internal/retry.(*Backoffer).Backoff(0xc001bee870, 0xc0004a89f0, 0x1f9edc0, 0xc000e1ad20, 0x0, 0x0)
/home/runner/work/client-go/client-go/internal/retry/backoff.go:120 +0xd8
github.com/tikv/client-go/v2/internal/locate.(*RegionCache).loadRegion(0xc00032f600, 0xc001bee870, 0xc001b33a32, 0x2, 0x2, 0x0, 0x0, 0x0, 0x0)
/home/runner/work/client-go/client-go/internal/locate/region_cache.go:1314 +0x871
github.com/tikv/client-go/v2/internal/locate.(*RegionCache).findRegionByKey(0xc00032f600, 0xc001bee870, 0xc001b33a32, 0x2, 0x2, 0x1be3c00, 0x1c749c0, 0x1d2817b, 0xd)
/home/runner/work/client-go/client-go/internal/locate/region_cache.go:819 +0x5f7
github.com/tikv/client-go/v2/internal/locate.(*RegionCache).LocateKey(0xc00032f600, 0xc001bee870, 0xc001b33a32, 0x2, 0x2, 0xc000d953e8, 0xc000d95398, 0x8b30f0)
/home/runner/work/client-go/client-go/internal/locate/region_cache.go:788 +0x79
github.com/tikv/client-go/v2/txnkv/transaction.groupSortedMutationsByRegion(0xc00032f600, 0xc001bee870, 0x1fe70b8, 0xc001cbe9c0, 0xb, 0x0, 0x0, 0x0, 0x0)
/home/runner/work/client-go/client-go/txnkv/transaction/2pc.go:765 +0x145
github.com/tikv/client-go/v2/txnkv/transaction.(*twoPhaseCommitter).groupMutations(0xc000e34600, 0xc001bee870, 0x1fe70b8, 0xc001cbe9c0, 0x4103f8, 0x18, 0x1b24a80, 0x0, 0x0)
/home/runner/work/client-go/client-go/txnkv/transaction/2pc.go:782 +0x85
github.com/tikv/client-go/v2/txnkv/transaction.(*twoPhaseCommitter).doActionOnMutations(0xc000e34600, 0xc001bee870, 0x1fc95b0, 0x350ec70, 0x1fe70b8, 0xc001cbe9c0, 0x0, 0x0)
/home/runner/work/client-go/client-go/txnkv/transaction/2pc.go:731 +0x75
github.com/tikv/client-go/v2/txnkv/transaction.(*twoPhaseCommitter).pessimisticRollbackMutations(...)
/home/runner/work/client-go/client-go/txnkv/transaction/pessimistic.go:319
github.com/tikv/client-go/v2/txnkv/transaction.actionPessimisticRollback.handleSingleBatch(0xc000e34600, 0xc001bee870, 0x2, 0x1, 0x1, 0x1fe70b8, 0xc001cbe9c0, 0x1, 0xd9ed48, 0x0)
/home/runner/work/client-go/client-go/txnkv/transaction/pessimistic.go:289 +0x308
github.com/tikv/client-go/v2/txnkv/transaction.(*twoPhaseCommitter).doActionOnBatches(0xc000e34600, 0xc001bee870, 0x1fc95b0, 0x350ec70, 0xc001cbc750, 0x1, 0x1, 0x4000, 0x7f0e6a7a45b8)
/home/runner/work/client-go/client-go/txnkv/transaction/2pc.go:982 +0xfc
github.com/tikv/client-go/v2/txnkv/transaction.(*twoPhaseCommitter).doActionOnGroupMutations(0xc000e34600, 0xc001bee870, 0x1fc95b0, 0x350ec70, 0xc001cbc720, 0x1, 0x1, 0x0, 0x0)
/home/runner/work/client-go/client-go/txnkv/transaction/2pc.go:963 +0xb19
github.com/tikv/client-go/v2/txnkv/transaction.(*twoPhaseCommitter).doActionOnMutations(0xc000e34600, 0xc001bee870, 0x1fc95b0, 0x350ec70, 0x1fe70b8, 0xc001cbe900, 0x29, 0x9)
/home/runner/work/client-go/client-go/txnkv/transaction/2pc.go:740 +0xf6
github.com/tikv/client-go/v2/txnkv/transaction.(*twoPhaseCommitter).pessimisticRollbackMutations(...)
/home/runner/work/client-go/client-go/txnkv/transaction/pessimistic.go:319
github.com/tikv/client-go/v2/txnkv/transaction.(*KVTxn).asyncPessimisticRollback.func1(0x1fce648, 0xc0000c6010, 0xc001bdab40, 0xc001bff0b0, 0xc000e34600, 0xc001b43470, 0x1, 0x1)
/home/runner/work/client-go/client-go/txnkv/transaction/txn.go:796 +0x1bf
created by github.com/tikv/client-go/v2/txnkv/transaction.(*KVTxn).asyncPessimisticRollback
/home/runner/work/client-go/client-go/txnkv/transaction/txn.go:779 +0x159
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with txnkv/transaction/txn.go around asyncPessimisticRollback and follow the stack through pessimistic.go, 2pc.go, locate/region_cache.go, and internal/retry/config.go. Reproduce the successful test run with goleak and inspect whether the goroutine remains after the test completes. Done means the reported unexpected goroutine no longer appears.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100