Fix data node

Signed-off-by: neza2017 <yefu.chen@zilliz.com>
This commit is contained in:
neza2017 2021-02-01 11:44:02 +08:00 committed by yefu.chen
parent 675426ea07
commit 3f45cfd6e8

View File

@ -56,6 +56,7 @@ type (
DataNode struct { DataNode struct {
ctx context.Context ctx context.Context
cancel context.CancelFunc
NodeID UniqueID NodeID UniqueID
Role string Role string
State internalpb2.StateCode State internalpb2.StateCode
@ -77,8 +78,10 @@ type (
func NewDataNode(ctx context.Context) *DataNode { func NewDataNode(ctx context.Context) *DataNode {
Params.Init() Params.Init()
ctx2, cancel2 := context.WithCancel(ctx)
node := &DataNode{ node := &DataNode{
ctx: ctx, ctx: ctx2,
cancel: cancel2,
NodeID: Params.NodeID, // GOOSE TODO How to init NodeID: Params.NodeID, // GOOSE TODO How to init
Role: typeutil.DataNodeRole, Role: typeutil.DataNodeRole,
State: internalpb2.StateCode_INITIALIZING, State: internalpb2.StateCode_INITIALIZING,
@ -216,7 +219,7 @@ func (node *DataNode) FlushSegments(in *datapb.FlushSegRequest) error {
} }
func (node *DataNode) Stop() error { func (node *DataNode) Stop() error {
<-node.ctx.Done() node.cancel()
// close services // close services
if node.dataSyncService != nil { if node.dataSyncService != nil {