tikvclient: fix a bug that double close channels. #10991
Signed-off-by: qupeng email@example.com
What problem does this PR solve?
There is a bug in tikvclient module about double closing channels, which causes some threads panic when holding a lock. Although these threads can recover, they will be blocked on that lock so they can't work finally.
What is changed and how it works?
This PR fixed the channel double closing problem, and use
@zz-jason I guess you didn't read the initial comment. Unit tests can't work for these cases because we need some real TiKV services to run tikvclient code. Currently we test tikvclient.go in 2 schrodinger test cases, we can add more cases there instead of here.
almost lgtm, but have some question..
can we do not call
it seems when
so it will trigger retry or http2Client#closeStream(will write error to recvBuffer), so it seems
..... but maybe do it in both side will more safe
@@ Coverage Diff @@ ## master #10991 +/- ## ================================================ - Coverage 81.5977% 81.1269% -0.4709% ================================================ Files 420 420 Lines 90902 89466 -1436 ================================================ - Hits 74174 72581 -1593 - Misses 11421 11630 +209 + Partials 5307 5255 -52