@@ -146,14 +146,19 @@ type Domain struct {
146
146
memoryUsageAlarmHandle * memoryusagealarm.Handle
147
147
serverMemoryLimitHandle * servermemorylimit.Handle
148
148
// TODO: use Run for each process in future pr
149
- wg * util.WaitGroupEnhancedWrapper
150
- statsUpdating atomicutil.Int32
151
- cancel context.CancelFunc
152
- indexUsageSyncLease time.Duration
153
- dumpFileGcChecker * dumpFileGcChecker
154
- planReplayerHandle * planReplayerHandle
155
- extractTaskHandle * ExtractHandle
156
- expiredTimeStamp4PC types.Time
149
+ wg * util.WaitGroupEnhancedWrapper
150
+ statsUpdating atomicutil.Int32
151
+ cancel context.CancelFunc
152
+ indexUsageSyncLease time.Duration
153
+ dumpFileGcChecker * dumpFileGcChecker
154
+ planReplayerHandle * planReplayerHandle
155
+ extractTaskHandle * ExtractHandle
156
+ expiredTimeStamp4PC struct {
157
+ // let `expiredTimeStamp4PC` use its own lock to avoid any block across domain.Reload()
158
+ // and compiler.Compile(), see issue https://github.com/pingcap/tidb/issues/45400
159
+ sync.RWMutex
160
+ expiredTimeStamp types.Time
161
+ }
157
162
logBackupAdvancer * daemon.OwnerDaemon
158
163
historicalStatsWorker * HistoricalStatsWorker
159
164
ttlJobManager atomic.Pointer [ttlworker.JobManager ]
@@ -472,18 +477,18 @@ func (do *Domain) GetSnapshotMeta(startTS uint64) (*meta.Meta, error) {
472
477
473
478
// ExpiredTimeStamp4PC gets expiredTimeStamp4PC from domain.
474
479
func (do * Domain ) ExpiredTimeStamp4PC () types.Time {
475
- do .m . Lock ()
476
- defer do .m . Unlock ()
480
+ do .expiredTimeStamp4PC . RLock ()
481
+ defer do .expiredTimeStamp4PC . RUnlock ()
477
482
478
- return do .expiredTimeStamp4PC
483
+ return do .expiredTimeStamp4PC . expiredTimeStamp
479
484
}
480
485
481
486
// SetExpiredTimeStamp4PC sets the expiredTimeStamp4PC from domain.
482
487
func (do * Domain ) SetExpiredTimeStamp4PC (time types.Time ) {
483
- do .m .Lock ()
484
- defer do .m .Unlock ()
488
+ do .expiredTimeStamp4PC .Lock ()
489
+ defer do .expiredTimeStamp4PC .Unlock ()
485
490
486
- do .expiredTimeStamp4PC = time
491
+ do .expiredTimeStamp4PC . expiredTimeStamp = time
487
492
}
488
493
489
494
// DDL gets DDL from domain.
@@ -1021,7 +1026,6 @@ func NewDomain(store kv.Storage, ddlLease time.Duration, statsLease time.Duratio
1021
1026
slowQuery : newTopNSlowQueries (30 , time .Hour * 24 * 7 , 500 ),
1022
1027
indexUsageSyncLease : idxUsageSyncLease ,
1023
1028
dumpFileGcChecker : & dumpFileGcChecker {gcLease : dumpFileGcLease , paths : []string {replayer .GetPlanReplayerDirName (), GetOptimizerTraceDirName (), GetExtractTaskDirName ()}},
1024
- expiredTimeStamp4PC : types .NewTime (types .ZeroCoreTime , mysql .TypeTimestamp , types .DefaultFsp ),
1025
1029
mdlCheckTableInfo : & mdlCheckTableInfo {
1026
1030
mu : sync.Mutex {},
1027
1031
jobsVerMap : make (map [int64 ]int64 ),
@@ -1037,6 +1041,7 @@ func NewDomain(store kv.Storage, ddlLease time.Duration, statsLease time.Duratio
1037
1041
do .serverMemoryLimitHandle = servermemorylimit .NewServerMemoryLimitHandle (do .exit )
1038
1042
do .sysProcesses = SysProcesses {mu : & sync.RWMutex {}, procMap : make (map [uint64 ]sessionctx.Context )}
1039
1043
do .initDomainSysVars ()
1044
+ do .expiredTimeStamp4PC .expiredTimeStamp = types .NewTime (types .ZeroCoreTime , mysql .TypeTimestamp , types .DefaultFsp )
1040
1045
return do
1041
1046
}
1042
1047
0 commit comments