Skip to content

Commit

Permalink
consolidate deferred functions
Browse files Browse the repository at this point in the history
Signed-off-by: Shlomi Noach <[email protected]>
  • Loading branch information
shlomi-noach committed Jan 18, 2024
1 parent 3bcfb19 commit e4f12d2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions go/vt/vttablet/tabletserver/throttle/throttler.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,10 +657,12 @@ func (throttler *Throttler) Operate(ctx context.Context, wg *sync.WaitGroup) {

wg.Add(1)
go func() {
defer wg.Done()
defer throttler.aggregatedMetrics.Flush()
defer throttler.recentApps.Flush()
defer throttler.nonLowPriorityAppRequestsThrottled.Flush()
defer func() {
throttler.aggregatedMetrics.Flush()
throttler.recentApps.Flush()
throttler.nonLowPriorityAppRequestsThrottled.Flush()
wg.Done()
}()
// we do not flush throttler.throttledApps because this is data submitted by the user; the user expects the data to survive a disable+enable

defer log.Infof("Throttler: Operate terminated, tickers stopped")
Expand Down

0 comments on commit e4f12d2

Please sign in to comment.