From f758f8ed782d7a8ddd1134c9481bc65d5b2491af Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Mon, 5 Aug 2024 14:21:40 +0800 Subject: [PATCH] server: create allocator no matter what mode (#8473) ref tikv/pd#8477 Signed-off-by: Ryan Leung Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> --- server/cluster/cluster.go | 2 +- server/server.go | 20 +++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/server/cluster/cluster.go b/server/cluster/cluster.go index d1f89ca2128..0638c3903b9 100644 --- a/server/cluster/cluster.go +++ b/server/cluster/cluster.go @@ -343,7 +343,7 @@ func (c *RaftCluster) Start(s Server) error { log.Error("load external timestamp meets error", zap.Error(err)) } - if s.IsAPIServiceMode() { + if c.isAPIServiceMode { // bootstrap keyspace group manager after starting other parts successfully. // This order avoids a stuck goroutine in keyspaceGroupManager when it fails to create raftcluster. err = c.keyspaceGroupManager.Bootstrap(c.ctx) diff --git a/server/server.go b/server/server.go index ce3c657ef46..7e0ee36278f 100644 --- a/server/server.go +++ b/server/server.go @@ -476,18 +476,16 @@ func (s *Server) startServer(ctx context.Context) error { s.tsoDispatcher = tsoutil.NewTSODispatcher(tsoProxyHandleDuration, tsoProxyBatchSize) s.tsoProtoFactory = &tsoutil.TSOProtoFactory{} s.pdProtoFactory = &tsoutil.PDProtoFactory{} - if !s.IsAPIServiceMode() { - s.tsoAllocatorManager = tso.NewAllocatorManager(s.ctx, mcs.DefaultKeyspaceGroupID, s.member, s.rootPath, s.storage, s, false) - // When disabled the Local TSO, we should clean up the Local TSO Allocator's meta info written in etcd if it exists. - if !s.cfg.EnableLocalTSO { - if err = s.tsoAllocatorManager.CleanUpDCLocation(); err != nil { - return err - } + s.tsoAllocatorManager = tso.NewAllocatorManager(s.ctx, mcs.DefaultKeyspaceGroupID, s.member, s.rootPath, s.storage, s, false) + // When disabled the Local TSO, we should clean up the Local TSO Allocator's meta info written in etcd if it exists. + if !s.cfg.EnableLocalTSO { + if err = s.tsoAllocatorManager.CleanUpDCLocation(); err != nil { + return err } - if zone, exist := s.cfg.Labels[config.ZoneLabel]; exist && zone != "" && s.cfg.EnableLocalTSO { - if err = s.tsoAllocatorManager.SetLocalTSOConfig(zone); err != nil { - return err - } + } + if zone, exist := s.cfg.Labels[config.ZoneLabel]; exist && zone != "" && s.cfg.EnableLocalTSO { + if err = s.tsoAllocatorManager.SetLocalTSOConfig(zone); err != nil { + return err } }