diff --git a/internal/datacoord/server.go b/internal/datacoord/server.go index d2cd6f9180a3c..e40e762e524c6 100644 --- a/internal/datacoord/server.go +++ b/internal/datacoord/server.go @@ -297,6 +297,8 @@ func (s *Server) initSession() error { // Init change server state to Initializing func (s *Server) Init() error { + s.UpdateStateCode(commonpb.StateCode_Initializing) + log := log.Ctx(s.ctx) var err error s.registerMetricsRequest() @@ -318,7 +320,7 @@ func (s *Server) Init() error { log.Info("DataCoord startup success") return nil } - s.stateCode.Store(commonpb.StateCode_StandBy) + s.UpdateStateCode(commonpb.StateCode_StandBy) log.Info("DataCoord enter standby mode successfully") return nil } @@ -326,9 +328,14 @@ func (s *Server) Init() error { return s.initDataCoord() } +// UpdateStateCode updates the status of the coord, including healthy, unhealthy +func (s *Server) UpdateStateCode(code commonpb.StateCode) { + s.stateCode.Store(code) + log.Info("update datacoord state", zap.String("state", code.String())) +} + func (s *Server) initDataCoord() error { log := log.Ctx(s.ctx) - s.stateCode.Store(commonpb.StateCode_Initializing) var err error if err = s.initRootCoordClient(); err != nil { return err @@ -463,7 +470,7 @@ func (s *Server) startDataCoord() { // }) s.afterStart() - s.stateCode.Store(commonpb.StateCode_Healthy) + s.UpdateStateCode(commonpb.StateCode_Healthy) sessionutil.SaveServerInfo(typeutil.DataCoordRole, s.session.GetServerID()) } diff --git a/internal/querycoordv2/server.go b/internal/querycoordv2/server.go index 25c7714a69681..4baf712b15227 100644 --- a/internal/querycoordv2/server.go +++ b/internal/querycoordv2/server.go @@ -248,6 +248,8 @@ func (s *Server) registerMetricsRequest() { } func (s *Server) Init() error { + s.UpdateStateCode(commonpb.StateCode_Initializing) + log := log.Ctx(s.ctx) log.Info("QueryCoord start init", zap.String("meta-root-path", Params.EtcdCfg.MetaRootPath.GetValue()), @@ -299,7 +301,6 @@ func (s *Server) initQueryCoord() error { } log.Info("QueryCoord report DataCoord ready") - s.UpdateStateCode(commonpb.StateCode_Initializing) log.Info("start init querycoord", zap.Any("State", commonpb.StateCode_Initializing)) // Init KV and ID allocator metaType := Params.MetaStoreCfg.MetaStoreType.GetValue() @@ -671,6 +672,7 @@ func (s *Server) Stop() error { // UpdateStateCode updates the status of the coord, including healthy, unhealthy func (s *Server) UpdateStateCode(code commonpb.StateCode) { s.status.Store(int32(code)) + log.Info("update querycoord state", zap.String("state", code.String())) } func (s *Server) State() commonpb.StateCode { diff --git a/internal/rootcoord/root_coord.go b/internal/rootcoord/root_coord.go index 7839e358da477..f815d5e3439af 100644 --- a/internal/rootcoord/root_coord.go +++ b/internal/rootcoord/root_coord.go @@ -447,8 +447,6 @@ func (c *Core) initInternal() error { defer initSpan.End() log := log.Ctx(initCtx) - c.UpdateStateCode(commonpb.StateCode_Initializing) - if err := c.initIDAllocator(initCtx); err != nil { return err } @@ -525,6 +523,8 @@ func (c *Core) registerMetricsRequest() { // Init initialize routine func (c *Core) Init() error { + c.UpdateStateCode(commonpb.StateCode_Initializing) + log := log.Ctx(c.ctx) var initError error c.registerMetricsRequest()