Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix rpc client panic cause by concurrent close #1359

Merged

Conversation

crazycs520
Copy link
Contributor

@crazycs520 crazycs520 commented May 31, 2024

close #1357

fix rpc client panic cause by concurrent close.

And add a test for it, before this PR, the run test with race flag will failed:

go test -race -run=TestConcurrentCloseConnPanic
panic: close of closed channel

goroutine 90 [running]:
github.com/tikv/client-go/v2/internal/client.(*batchConn).Close(...)
        /Users/cs/code/goread/src/github.com/pingcap/client-go/internal/client/client_batch.go:891
github.com/tikv/client-go/v2/internal/client.(*connArray).Close(0xc00014a240)
        /Users/cs/code/goread/src/github.com/pingcap/client-go/internal/client/client.go:384 +0xdc
github.com/tikv/client-go/v2/internal/client.(*RPCClient).CloseAddrVer(0xc00011e230, {0x10503ec2e, 0xe}, 0xffffffffffffffff)
        /Users/cs/code/goread/src/github.com/pingcap/client-go/internal/client/client.go:876 +0x500
github.com/tikv/client-go/v2/internal/client.(*RPCClient).CloseAddr(...)
        /Users/cs/code/goread/src/github.com/pingcap/client-go/internal/client/client.go:858
github.com/tikv/client-go/v2/internal/client.TestConcurrentCloseConnPanic.func2()
        /Users/cs/code/goread/src/github.com/pingcap/client-go/internal/client/client_test.go:1065 +0xa4
created by github.com/tikv/client-go/v2/internal/client.TestConcurrentCloseConnPanic in goroutine 8
        /Users/cs/code/goread/src/github.com/pingcap/client-go/internal/client/client_test.go:1063 +0x2b8
exit status 2
FAIL    github.com/tikv/client-go/v2/internal/client    0.341s

@crazycs520 crazycs520 marked this pull request as ready for review May 31, 2024 08:37
Signed-off-by: crazycs520 <[email protected]>
Signed-off-by: crazycs520 <[email protected]>
@cfzjywxk cfzjywxk merged commit cb580bc into tikv:master May 31, 2024
10 checks passed
@crazycs520 crazycs520 deleted the fix-concurrent-close-conn-panic-master branch May 31, 2024 11:01
crazycs520 added a commit to crazycs520/client-go that referenced this pull request Jul 24, 2024
crazycs520 added a commit to crazycs520/client-go that referenced this pull request Jul 24, 2024
close issue tikv#1357

Signed-off-by: crazycs520 <[email protected]>

---------

Signed-off-by: crazycs520 <[email protected]>
crazycs520 added a commit to crazycs520/client-go that referenced this pull request Jul 24, 2024
close issue tikv#1357

Signed-off-by: crazycs520 <[email protected]>

---------

Signed-off-by: crazycs520 <[email protected]>
MyonKeminta pushed a commit that referenced this pull request Jul 31, 2024
cfzjywxk pushed a commit that referenced this pull request Aug 21, 2024
cfzjywxk pushed a commit that referenced this pull request Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kvclient panic when kill pd leader during br backup
4 participants