This commit is contained in:
Tim Vaillancourt 2022-07-07 03:19:53 +02:00
parent 500fbefdb9
commit 0ec555badf

View File

@ -247,15 +247,14 @@ func (this *Throttler) collectControlReplicasLag() {
this.migrationContext.SetControlReplicasLagResult(readControlReplicasLag()) this.migrationContext.SetControlReplicasLagResult(readControlReplicasLag())
} }
aggressiveTicker := time.NewTicker(100 * time.Millisecond)
defer aggressiveTicker.Stop()
relaxedFactor := 10 relaxedFactor := 10
counter := 0 counter := 0
shouldReadLagAggressively := false shouldReadLagAggressively := false
ticker := time.NewTicker(100 * time.Millisecond)
defer ticker.Stop()
for { for {
<-aggressiveTicker.C <-ticker.C
if atomic.LoadInt64(&this.finishedMigrating) > 0 { if atomic.LoadInt64(&this.finishedMigrating) > 0 {
return return
} }
@ -464,9 +463,6 @@ func (this *Throttler) initiateThrottlerCollection(firstThrottlingCollected chan
// initiateThrottlerChecks initiates the throttle ticker and sets the basic behavior of throttling. // initiateThrottlerChecks initiates the throttle ticker and sets the basic behavior of throttling.
func (this *Throttler) initiateThrottlerChecks() { func (this *Throttler) initiateThrottlerChecks() {
throttlerTick := time.NewTicker(100 * time.Millisecond)
defer throttlerTick.Stop()
throttlerFunction := func() { throttlerFunction := func() {
alreadyThrottling, currentReason, _ := this.migrationContext.IsThrottled() alreadyThrottling, currentReason, _ := this.migrationContext.IsThrottled()
shouldThrottle, throttleReason, throttleReasonHint := this.shouldThrottle() shouldThrottle, throttleReason, throttleReasonHint := this.shouldThrottle()
@ -483,8 +479,11 @@ func (this *Throttler) initiateThrottlerChecks() {
this.migrationContext.SetThrottled(shouldThrottle, throttleReason, throttleReasonHint) this.migrationContext.SetThrottled(shouldThrottle, throttleReason, throttleReasonHint)
} }
throttlerFunction() throttlerFunction()
ticker := time.NewTicker(100 * time.Millisecond)
defer ticker.Stop()
for { for {
<-throttlerTick.C <-ticker.C
if atomic.LoadInt64(&this.finishedMigrating) > 0 { if atomic.LoadInt64(&this.finishedMigrating) > 0 {
return return
} }