From 80c98e174c6131c544cf8411686a22611011bf88 Mon Sep 17 00:00:00 2001 From: lhy1024 Date: Fri, 8 Nov 2024 14:26:52 +0800 Subject: [PATCH] cluster: avoid unexpect scheduling job start 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