mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 11:59:00 +08:00
Fix reading config from etcd may block forever (#21688)
Signed-off-by: yah01 <yang.cen@zilliz.com>
This commit is contained in:
parent
f8e1566b24
commit
f4d80b4211
@ -21,11 +21,16 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/milvus-io/milvus/internal/util/etcd"
|
||||
clientv3 "go.etcd.io/etcd/client/v3"
|
||||
)
|
||||
|
||||
const (
|
||||
ReadConfigTimeout = 3 * time.Second
|
||||
)
|
||||
|
||||
type EtcdSource struct {
|
||||
sync.RWMutex
|
||||
etcdCli *clientv3.Client
|
||||
@ -108,7 +113,9 @@ func (es *EtcdSource) SetEventHandler(eh EventHandler) {
|
||||
|
||||
func (es *EtcdSource) refreshConfigurations() error {
|
||||
prefix := es.keyPrefix + "/config"
|
||||
response, err := es.etcdCli.Get(es.ctx, prefix, clientv3.WithPrefix())
|
||||
ctx, cancel := context.WithTimeout(es.ctx, ReadConfigTimeout)
|
||||
defer cancel()
|
||||
response, err := es.etcdCli.Get(ctx, prefix, clientv3.WithPrefix())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user