Fix proxy ut may hang with dn graceful stop (#8124)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2021-09-17 17:49:58 +08:00 committed by GitHub
parent b84f017dde
commit a972fafb5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -141,7 +141,21 @@ func (s *Server) Stop() error {
}
s.cancel()
if s.grpcServer != nil {
s.grpcServer.GracefulStop()
// make graceful stop has a timeout
stopped := make(chan struct{})
go func() {
s.grpcServer.GracefulStop()
close(stopped)
}()
t := time.NewTimer(10 * time.Second)
select {
case <-t.C:
// hard stop since grace timeout
s.grpcServer.Stop()
case <-stopped:
t.Stop()
}
}
err := s.datanode.Stop()