diff options
author | zeripath <art27@cantab.net> | 2021-05-12 00:22:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-12 00:22:08 +0100 |
commit | aa65a607e428c2221a6c8f0b3156e0b58d35251b (patch) | |
tree | 3013446f3a40751ba344f083414ef01790b0f66e /modules/queue | |
parent | 793e03244b1e7d16eee0884c7a19212fdcd16d84 (diff) | |
download | gitea-aa65a607e428c2221a6c8f0b3156e0b58d35251b.tar.gz gitea-aa65a607e428c2221a6c8f0b3156e0b58d35251b.zip |
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>
Diffstat (limited to 'modules/queue')
-rw-r--r-- | modules/queue/manager.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/modules/queue/manager.go b/modules/queue/manager.go index da0fc606e6..c3ec735af5 100644 --- a/modules/queue/manager.go +++ b/modules/queue/manager.go @@ -198,17 +198,20 @@ func (m *Manager) FlushAll(baseCtx context.Context, timeout time.Duration) error wg.Done() }(mq) } else { - log.Debug("Queue: %s is non-empty but is not flushable - adding 100 millisecond wait", mq.Name) - go func() { - <-time.After(100 * time.Millisecond) - wg.Done() - }() + log.Debug("Queue: %s is non-empty but is not flushable", mq.Name) + wg.Done() } - } if allEmpty { + log.Debug("All queues are empty") 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() } return nil |