File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -561,7 +561,11 @@ func (this *MigrationContext) GetControlReplicasLagResult() mysql.ReplicationLag
561561func (this * MigrationContext ) SetControlReplicasLagResult (lagResult * mysql.ReplicationLagResult ) {
562562 this .throttleMutex .Lock ()
563563 defer this .throttleMutex .Unlock ()
564- this .controlReplicasLagResult = * lagResult
564+ if lagResult == nil {
565+ this .controlReplicasLagResult = * mysql .NewNoReplicationLagResult ()
566+ } else {
567+ this .controlReplicasLagResult = * lagResult
568+ }
565569}
566570
567571func (this * MigrationContext ) GetThrottleControlReplicaKeys () * mysql.InstanceKeyMap {
Original file line number Diff line number Diff line change @@ -176,9 +176,7 @@ func (this *Throttler) collectControlReplicasLag() {
176176 // No need to read lag
177177 return
178178 }
179- if result := readControlReplicasLag (); result != nil {
180- this .migrationContext .SetControlReplicasLagResult (result )
181- }
179+ this .migrationContext .SetControlReplicasLagResult (readControlReplicasLag ())
182180 }
183181 aggressiveTicker := time .Tick (100 * time .Millisecond )
184182 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