@@ -79,6 +79,8 @@ type MigrationContext struct {
79
79
LockTablesStartTime time.Time
80
80
RenameTablesStartTime time.Time
81
81
RenameTablesEndTime time.Time
82
+ pointOfInterestTime time.Time
83
+ pointOfInterestTimeMutex * sync.Mutex
82
84
CurrentLag int64
83
85
TotalRowsCopied int64
84
86
TotalDMLEventsApplied int64
@@ -131,6 +133,7 @@ func newMigrationContext() *MigrationContext {
131
133
throttleMutex : & sync.Mutex {},
132
134
ThrottleControlReplicaKeys : mysql .NewInstanceKeyMap (),
133
135
configMutex : & sync.Mutex {},
136
+ pointOfInterestTimeMutex : & sync.Mutex {},
134
137
}
135
138
}
136
139
@@ -216,16 +219,31 @@ func (this *MigrationContext) GetIteration() int64 {
216
219
return atomic .LoadInt64 (& this .Iteration )
217
220
}
218
221
222
+ func (this * MigrationContext ) MarkPointOfInterest () int64 {
223
+ this .pointOfInterestTimeMutex .Lock ()
224
+ defer this .pointOfInterestTimeMutex .Unlock ()
225
+
226
+ this .pointOfInterestTime = time .Now ()
227
+ return atomic .LoadInt64 (& this .Iteration )
228
+ }
229
+
230
+ func (this * MigrationContext ) TimeSincePointOfInterest () time.Duration {
231
+ this .pointOfInterestTimeMutex .Lock ()
232
+ defer this .pointOfInterestTimeMutex .Unlock ()
233
+
234
+ return time .Now ().Sub (this .pointOfInterestTime )
235
+ }
236
+
219
237
func (this * MigrationContext ) SetThrottled (throttle bool , reason string ) {
220
238
this .throttleMutex .Lock ()
221
- defer func () { this .throttleMutex .Unlock () } ()
239
+ defer this .throttleMutex .Unlock ()
222
240
this .isThrottled = throttle
223
241
this .throttleReason = reason
224
242
}
225
243
226
244
func (this * MigrationContext ) IsThrottled () (bool , string ) {
227
245
this .throttleMutex .Lock ()
228
- defer func () { this .throttleMutex .Unlock () } ()
246
+ defer this .throttleMutex .Unlock ()
229
247
return this .isThrottled , this .throttleReason
230
248
}
231
249
0 commit comments