From 18706f62055b0833eda2ac01cdd0322ec7addf46 Mon Sep 17 00:00:00 2001 From: YangKeao Date: Thu, 2 Feb 2023 23:15:57 +0800 Subject: [PATCH] ttl: fix data race in TTL manager and test (#40976) close pingcap/tidb#40944 --- domain/domain.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/domain/domain.go b/domain/domain.go index 3f1c833b148c0..67341449876d4 100644 --- a/domain/domain.go +++ b/domain/domain.go @@ -133,7 +133,7 @@ type Domain struct { expiredTimeStamp4PC types.Time logBackupAdvancer *daemon.OwnerDaemon historicalStatsWorker *HistoricalStatsWorker - ttlJobManager *ttlworker.JobManager + ttlJobManager atomic.Pointer[ttlworker.JobManager] serverID uint64 serverIDSession *concurrency.Session @@ -2513,7 +2513,7 @@ func (do *Domain) StartTTLJobManager() { }() ttlJobManager := ttlworker.NewJobManager(do.ddl.GetID(), do.sysSessionPool, do.store, do.etcdClient) - do.ttlJobManager = ttlJobManager + do.ttlJobManager.Store(ttlJobManager) ttlJobManager.Start() <-do.exit @@ -2528,7 +2528,7 @@ func (do *Domain) StartTTLJobManager() { // TTLJobManager returns the ttl job manager on this domain func (do *Domain) TTLJobManager() *ttlworker.JobManager { - return do.ttlJobManager + return do.ttlJobManager.Load() } func init() {