mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-23 07:43:18 -05:00
Queue manager FlushAll can loop rapidly - add delay (#15733)
* Queue manager FlushAll can loop rapidly - add delay Add delay within FlushAll to prevent rapid loop when workers are busy Signed-off-by: Andrew Thornton <art27@cantab.net> * as per lunny Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
793e03244b
commit
aa65a607e4
1 changed files with 9 additions and 6 deletions
|
@ -198,17 +198,20 @@ func (m *Manager) FlushAll(baseCtx context.Context, timeout time.Duration) error
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}(mq)
|
}(mq)
|
||||||
} else {
|
} else {
|
||||||
log.Debug("Queue: %s is non-empty but is not flushable - adding 100 millisecond wait", mq.Name)
|
log.Debug("Queue: %s is non-empty but is not flushable", mq.Name)
|
||||||
go func() {
|
wg.Done()
|
||||||
<-time.After(100 * time.Millisecond)
|
|
||||||
wg.Done()
|
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if allEmpty {
|
if allEmpty {
|
||||||
|
log.Debug("All queues are empty")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
// Ensure there are always at least 100ms between loops but not more if we've actually been doing some flushign
|
||||||
|
// but don't delay cancellation here.
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
case <-time.After(100 * time.Millisecond):
|
||||||
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue