From 49307e21538c3821d64ff82a7b00115d9c24073c Mon Sep 17 00:00:00 2001 From: lhy1024 Date: Fri, 8 Nov 2024 14:46:51 +0800 Subject: [PATCH] cluster: avoid unexpect scheduling job start (#8794) ref tikv/pd#8781 Signed-off-by: lhy1024 --- server/cluster/cluster.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/cluster/cluster.go b/server/cluster/cluster.go index 6f70e6cfeaf..12ce8f45102 100644 --- a/server/cluster/cluster.go +++ b/server/cluster/cluster.go @@ -458,7 +458,13 @@ func (c *RaftCluster) runServiceCheckJob() { log.Info("service check job is stopped") return case <-schedulingTicker.C: - c.checkSchedulingService() + // ensure raft cluster is running + // avoid unexpected startSchedulingJobs when raft cluster is stopping + c.RLock() + if c.running { + c.checkSchedulingService() + } + c.RUnlock() case <-tsoTicker.C: // ensure raft cluster is running // avoid unexpected startTSOJobsIfNeeded when raft cluster is stopping