Start once for IndexNode (#8170)

Signed-off-by: cai.zhang <cai.zhang@zilliz.com>
This commit is contained in:
cai.zhang 2021-09-24 20:37:56 +08:00 committed by GitHub
parent 82c28d225c
commit 93c912e681
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,6 +62,8 @@ type IndexNode struct {
sched *TaskScheduler
once sync.Once
kv kv.BaseKV
session *sessionutil.Session
liveCh <-chan bool
@ -161,20 +163,25 @@ func (i *IndexNode) Init() error {
}
func (i *IndexNode) Start() error {
i.sched.Start()
var startErr error = nil
i.once.Do(func() {
startErr = i.sched.Start()
//start liveness check
go i.session.LivenessCheck(i.loopCtx, i.liveCh, func() {
i.Stop()
//start liveness check
go i.session.LivenessCheck(i.loopCtx, i.liveCh, func() {
i.Stop()
})
i.UpdateStateCode(internalpb.StateCode_Healthy)
log.Debug("IndexNode", zap.Any("State", i.stateCode.Load()))
})
i.UpdateStateCode(internalpb.StateCode_Healthy)
log.Debug("IndexNode", zap.Any("State", i.stateCode.Load()))
// Start callbacks
for _, cb := range i.startCallbacks {
cb()
}
return nil
log.Debug("IndexNode start finished", zap.Error(startErr))
return startErr
}
// Stop Close closes the server.