Refine standalone components stop order (#26742)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/26783/head
congqixia 2023-08-31 16:51:02 +08:00 committed by GitHub
parent 3752ebb4c9
commit 4bf26dd4ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 39 additions and 24 deletions

View File

@ -267,6 +267,8 @@ func (mr *MilvusRoles) handleSignals() func() {
log.Warn("Get signal to exit", zap.String("signal", sig.String()))
mr.once.Do(func() {
close(mr.closed)
// reset other signals, only handle SIGINT from now
signal.Reset(syscall.SIGQUIT, syscall.SIGHUP, syscall.SIGTERM)
})
}
}
@ -321,65 +323,41 @@ func (mr *MilvusRoles) Run(local bool, alias string) {
var wg sync.WaitGroup
if mr.EnableRootCoord {
rc = mr.runRootCoord(ctx, local, &wg)
if rc != nil {
defer rc.Stop()
}
}
var pn *components.Proxy
if mr.EnableProxy {
pn = mr.runProxy(ctx, local, &wg)
if pn != nil {
defer pn.Stop()
}
}
var qs *components.QueryCoord
if mr.EnableQueryCoord {
qs = mr.runQueryCoord(ctx, local, &wg)
if qs != nil {
defer qs.Stop()
}
}
var qn *components.QueryNode
if mr.EnableQueryNode {
qn = mr.runQueryNode(ctx, local, &wg)
if qn != nil {
defer qn.Stop()
}
}
var ds *components.DataCoord
if mr.EnableDataCoord {
ds = mr.runDataCoord(ctx, local, &wg)
if ds != nil {
defer ds.Stop()
}
}
var dn *components.DataNode
if mr.EnableDataNode {
dn = mr.runDataNode(ctx, local, &wg)
if dn != nil {
defer dn.Stop()
}
}
var is *components.IndexCoord
if mr.EnableIndexCoord {
is = mr.runIndexCoord(ctx, local, &wg)
if is != nil {
defer is.Stop()
}
}
var in *components.IndexNode
if mr.EnableIndexNode {
in = mr.runIndexNode(ctx, local, &wg)
if in != nil {
defer in.Stop()
}
}
wg.Wait()
@ -392,4 +370,41 @@ func (mr *MilvusRoles) Run(local bool, alias string) {
paramtable.SetUpdateTime(time.Now())
<-mr.closed
// stop coordinators first
// var component
coordinators := []component{rc, qs, ds, is}
for _, coord := range coordinators {
if coord != nil {
wg.Add(1)
go func(coord component) {
defer wg.Done()
coord.Stop()
}(coord)
}
}
wg.Wait()
log.Info("All coordinators have stopped")
// stop nodes
nodes := []component{qn, in, dn}
for _, node := range nodes {
if node != nil {
wg.Add(1)
go func(node component) {
defer wg.Done()
node.Stop()
}(node)
}
}
wg.Wait()
log.Info("All nodes have stopped")
// stop proxy
if pn != nil {
pn.Stop()
log.Info("proxy stopped")
}
log.Info("Milvus components graceful stop done")
}