pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.2k stars 5.84k forks source link

goleak in the sendBatchRequest #31990

Closed hawkingrei closed 2 years ago

hawkingrei commented 2 years ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

test session with real tikv suites testPessimisticSuite / TestMain – 

Error
Failed
Stacktrace
PASS
goleak: Errors on successful test run: found unexpected goroutines:
[Goroutine 72031 in state select, with github.com/tikv/client-go/v2/internal/client.sendBatchRequest on top of the stack:
goroutine 72031 [select]:
github.com/tikv/client-go/v2/internal/client.sendBatchRequest(0x45f4980, 0xc000064090, 0xc0028880a0, 0xf, 0x0, 0x0, 0xc006844900, 0xc0028f9500, 0x6fc23ac00, 0x0, ...)
    /go/pkg/mod/github.com/tikv/client-go/v2@v2.0.0-rc.0.20211229051614-62d6b4a2e8f7/internal/client/client_batch.go:786 +0x878
github.com/tikv/client-go/v2/internal/client.(*RPCClient).SendRequest(0xc004206480, 0x45f4980, 0xc000064090, 0xc0028880a0, 0xf, 0xc0035b6780, 0x6fc23ac00, 0x0, 0x0, 0x0)
    /go/pkg/mod/github.com/tikv/client-go/v2@v2.0.0-rc.0.20211229051614-62d6b4a2e8f7/internal/client/client.go:405 +0xa70
github.com/tikv/client-go/v2/internal/client.interceptedClient.SendRequest(0x45cf4d8, 0xc004206480, 0x45f4980, 0xc000064090, 0xc0028880a0, 0xf, 0xc0035b6780, 0x6fc23ac00, 0xc000800000, 0x3be7ee0, ...)
    /go/pkg/mod/github.com/tikv/client-go/v2@v2.0.0-rc.0.20211229051614-62d6b4a2e8f7/internal/client/client_interceptor.go:42 +0x1e9
github.com/tikv/client-go/v2/internal/client.reqCollapse.SendRequest(0x45d1e90, 0xc005666d40, 0x45f4980, 0xc000064090, 0xc0028880a0, 0xf, 0xc0035b6780, 0x6fc23ac00, 0x61f0f6ff, 0xc0063197a6, ...)
    /go/pkg/mod/github.com/tikv/client-go/v2@v2.0.0-rc.0.20211229051614-62d6b4a2e8f7/internal/client/client_collapse.go:74 +0x12a
github.com/tikv/client-go/v2/internal/locate.(*RegionRequestSender).sendReqToRegion(0xc0065e7860, 0xc00217cb40, 0xc000afb3b0, 0xc0035b6780, 0x6fc23ac00, 0x0, 0x0, 0x0, 0x0)
    /go/pkg/mod/github.com/tikv/client-go/v2@v2.0.0-rc.0.20211229051614-62d6b4a2e8f7/internal/locate/region_request.go:1130 +0x8f0
github.com/tikv/client-go/v2/internal/locate.(*RegionRequestSender).SendReqCtx(0xc0065e7860, 0xc00217cb40, 0xc0035b6780, 0x2, 0x1, 0x1, 0x6fc23ac00, 0x1e6c900, 0x0, 0x0, ...)
    /go/pkg/mod/github.com/tikv/client-go/v2@v2.0.0-rc.0.20211229051614-62d6b4a2e8f7/internal/locate/region_request.go:982 +0x474
github.com/tikv/client-go/v2/internal/locate.(*RegionRequestSender).SendReq(...)
    /go/pkg/mod/github.com/tikv/client-go/v2@v2.0.0-rc.0.20211229051614-62d6b4a2e8f7/internal/locate/region_request.go:231
github.com/tikv/client-go/v2/tikv.(*KVStore).SendReq(0xc00187d180, 0xc00217cb40, 0xc0035b6780, 0x2, 0x1, 0x1, 0x6fc23ac00, 0x0, 0xc0065e7990, 0x1300e3b)
    /go/pkg/mod/github.com/tikv/client-go/v2@v2.0.0-rc.0.20211229051614-62d6b4a2e8f7/tikv/kv.go:394 +0x117
github.com/tikv/client-go/v2/txnkv/transaction.sendTxnHeartBeat(0xc00217cb40, 0x46309c0, 0xc00187d180, 0xc004c81140, 0x13, 0x13, 0x5fa550d6ea4000b, 0x179ee, 0x17958, 0x0, ...)
    /go/pkg/mod/github.com/tikv/client-go/v2@v2.0.0-rc.0.20211229051614-62d6b4a2e8f7/txnkv/transaction/2pc.go:998 +0x1b7
github.com/tikv/client-go/v2/txnkv/transaction.keepAlive(0xc003c5f200, 0xc0005e9b60, 0xc004c81140, 0x13, 0x13, 0xc0016ffea0)
    /go/pkg/mod/github.com/tikv/client-go/v2@v2.0.0-rc.0.20211229051614-62d6b4a2e8f7/txnkv/transaction/2pc.go:964 +0x585
created by github.com/tikv/client-go/v2/txnkv/transaction.(*ttlManager).run
    /go/pkg/mod/github.com/tikv/client-go/v2@v2.0.0-rc.0.20211229051614-62d6b4a2e8f7/txnkv/transaction/2pc.go:900 +0xfe
]

https://ci.pingcap.net/blue/organizations/jenkins/tidb_ghpr_check_2/detail/tidb_ghpr_check_2/62914/tests

2. What did you expect to see? (Required)

3. What did you see instead (Required)

4. What is your TiDB version? (Required)

github-actions[bot] commented 2 years ago

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.