File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -559,7 +559,11 @@ func (this *MigrationContext) GetControlReplicasLagResult() mysql.ReplicationLag
559559func (this * MigrationContext ) SetControlReplicasLagResult (lagResult * mysql.ReplicationLagResult ) {
560560 this .throttleMutex .Lock ()
561561 defer this .throttleMutex .Unlock ()
562- this .controlReplicasLagResult = * lagResult
562+ if lagResult == nil {
563+ this .controlReplicasLagResult = * mysql .NewNoReplicationLagResult ()
564+ } else {
565+ this .controlReplicasLagResult = * lagResult
566+ }
563567}
564568
565569func (this * MigrationContext ) GetThrottleControlReplicaKeys () * mysql.InstanceKeyMap {
Original file line number Diff line number Diff line change @@ -158,9 +158,7 @@ func (this *Throttler) collectControlReplicasLag() {
158158 // No need to read lag
159159 return
160160 }
161- if result := readControlReplicasLag (); result != nil {
162- this .migrationContext .SetControlReplicasLagResult (result )
163- }
161+ this .migrationContext .SetControlReplicasLagResult (readControlReplicasLag ())
164162 }
165163 aggressiveTicker := time .Tick (100 * time .Millisecond )
166164 relaxedFactor := 10
Original file line number Diff line number Diff line change @@ -22,6 +22,14 @@ type ReplicationLagResult struct {
2222 Err error
2323}
2424
25+ func NewNoReplicationLagResult () * ReplicationLagResult {
26+ return & ReplicationLagResult {Lag : 0 , Err : nil }
27+ }
28+
29+ func (this * ReplicationLagResult ) HasLag () bool {
30+ return this .Lag > 0
31+ }
32+
2533// GetReplicationLag returns replication lag for a given connection config; either by explicit query
2634// or via SHOW SLAVE STATUS
2735func GetReplicationLag (connectionConfig * ConnectionConfig ) (replicationLag time.Duration , err error ) {
You can’t perform that action at this time.
0 commit comments