@@ -118,10 +118,15 @@ type Domain struct {
118
118
indexUsageSyncLease time.Duration
119
119
dumpFileGcChecker * dumpFileGcChecker
120
120
planReplayerHandle * planReplayerHandle
121
- expiredTimeStamp4PC types.Time
122
- logBackupAdvancer * daemon.OwnerDaemon
123
- historicalStatsWorker * HistoricalStatsWorker
124
- ttlJobManager * ttlworker.JobManager
121
+ expiredTimeStamp4PC struct {
122
+ // let `expiredTimeStamp4PC` use its own lock to avoid any block across domain.Reload()
123
+ // and compiler.Compile(), see issue https://github.com/pingcap/tidb/issues/45400
124
+ sync.RWMutex
125
+ expiredTimeStamp types.Time
126
+ }
127
+ logBackupAdvancer * daemon.OwnerDaemon
128
+ historicalStatsWorker * HistoricalStatsWorker
129
+ ttlJobManager * ttlworker.JobManager
125
130
126
131
serverID uint64
127
132
serverIDSession * concurrency.Session
@@ -394,18 +399,18 @@ func (do *Domain) GetSnapshotMeta(startTS uint64) (*meta.Meta, error) {
394
399
395
400
// ExpiredTimeStamp4PC gets expiredTimeStamp4PC from domain.
396
401
func (do * Domain ) ExpiredTimeStamp4PC () types.Time {
397
- do .m . Lock ()
398
- defer do .m . Unlock ()
402
+ do .expiredTimeStamp4PC . RLock ()
403
+ defer do .expiredTimeStamp4PC . RUnlock ()
399
404
400
- return do .expiredTimeStamp4PC
405
+ return do .expiredTimeStamp4PC . expiredTimeStamp
401
406
}
402
407
403
408
// SetExpiredTimeStamp4PC sets the expiredTimeStamp4PC from domain.
404
409
func (do * Domain ) SetExpiredTimeStamp4PC (time types.Time ) {
405
- do .m .Lock ()
406
- defer do .m .Unlock ()
410
+ do .expiredTimeStamp4PC .Lock ()
411
+ defer do .expiredTimeStamp4PC .Unlock ()
407
412
408
- do .expiredTimeStamp4PC = time
413
+ do .expiredTimeStamp4PC . expiredTimeStamp = time
409
414
}
410
415
411
416
// DDL gets DDL from domain.
@@ -898,7 +903,6 @@ func NewDomain(store kv.Storage, ddlLease time.Duration, statsLease time.Duratio
898
903
slowQuery : newTopNSlowQueries (30 , time .Hour * 24 * 7 , 500 ),
899
904
indexUsageSyncLease : idxUsageSyncLease ,
900
905
dumpFileGcChecker : & dumpFileGcChecker {gcLease : dumpFileGcLease , paths : []string {GetPlanReplayerDirName (), GetOptimizerTraceDirName ()}},
901
- expiredTimeStamp4PC : types .NewTime (types .ZeroCoreTime , mysql .TypeTimestamp , types .DefaultFsp ),
902
906
mdlCheckTableInfo : & mdlCheckTableInfo {
903
907
mu : sync.Mutex {},
904
908
jobsVerMap : make (map [int64 ]int64 ),
@@ -913,6 +917,7 @@ func NewDomain(store kv.Storage, ddlLease time.Duration, statsLease time.Duratio
913
917
do .serverMemoryLimitHandle = servermemorylimit .NewServerMemoryLimitHandle (do .exit )
914
918
do .sysProcesses = SysProcesses {mu : & sync.RWMutex {}, procMap : make (map [uint64 ]sessionctx.Context )}
915
919
do .initDomainSysVars ()
920
+ do .expiredTimeStamp4PC .expiredTimeStamp = types .NewTime (types .ZeroCoreTime , mysql .TypeTimestamp , types .DefaultFsp )
916
921
return do
917
922
}
918
923
0 commit comments