proxy/grpcproxy: make sure watchproxy do not block forever when failed to cancel a watcher

This commit is contained in:
tangcong 2020-06-19 13:43:31 +08:00
parent d8c8f903ee
commit b5a07728d0

View File

@ -17,6 +17,7 @@ package grpcproxy
import ( import (
"context" "context"
"sync" "sync"
"time"
"go.etcd.io/etcd/v3/clientv3" "go.etcd.io/etcd/v3/clientv3"
pb "go.etcd.io/etcd/v3/etcdserver/etcdserverpb" pb "go.etcd.io/etcd/v3/etcdserver/etcdserverpb"
@ -148,5 +149,12 @@ func (wb *watchBroadcast) stop() {
} }
wb.cancel() wb.cancel()
<-wb.donec
select {
case <-wb.donec:
// watchProxyStream will hold watchRanges global mutex lock all the time if client failed to cancel etcd watchers.
// and it will cause the watch proxy to not work.
// please see pr https://github.com/etcd-io/etcd/pull/12030 to get more detail info.
case <-time.After(time.Second):
}
} }