Skip to content

Commit

Permalink
client: fix the leak of the keyspace watch channel (tikv#6494)
Browse files Browse the repository at this point in the history
ref tikv#4399

Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx committed Aug 2, 2023
1 parent 08408d2 commit 6a530a1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion client/keyspace_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func (c *client) WatchKeyspaces(ctx context.Context) (chan []*keyspacepb.Keyspac
}
go func() {
defer func() {
close(keyspaceWatcherChan)
if r := recover(); r != nil {
log.Error("[pd] panic in keyspace client `WatchKeyspaces`", zap.Any("error", r))
return
Expand All @@ -99,7 +100,6 @@ func (c *client) WatchKeyspaces(ctx context.Context) (chan []*keyspacepb.Keyspac
for {
select {
case <-ctx.Done():
close(keyspaceWatcherChan)
return
default:
resp, err := stream.Recv()
Expand Down

0 comments on commit 6a530a1

Please sign in to comment.