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

release-3.5
tangcong 2020-06-19 13:43:31 +08:00
parent d8c8f903ee
commit b5a07728d0
1 changed files with 9 additions and 1 deletions

View File

@ -17,6 +17,7 @@ package grpcproxy
import (
"context"
"sync"
"time"
"go.etcd.io/etcd/v3/clientv3"
pb "go.etcd.io/etcd/v3/etcdserver/etcdserverpb"
@ -148,5 +149,12 @@ func (wb *watchBroadcast) stop() {
}
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):
}
}