summaryrefslogtreecommitdiffstats
path: root/modules/queue
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-08-30 05:27:51 +0100
committerGitHub <noreply@github.com>2021-08-30 00:27:51 -0400
commit06b9d553bc02f88553ced9822c55ae901e2ac28e (patch)
tree9c942f976fd58d8e5ef7a466732f61aa296084cf /modules/queue
parentb0ff42988249648999acc76198a11a4eefddbb9a (diff)
downloadgitea-06b9d553bc02f88553ced9822c55ae901e2ac28e.tar.gz
gitea-06b9d553bc02f88553ced9822c55ae901e2ac28e.zip
Timeout on flush in testing (#16864)
* Timeout on flush in testing At the end of each test the queues are flushed. At present there is no limit on the length of time a flush can take which can lead to long flushes. However, if the CI task is cancelled we lose the log information as to where the long flush was taking place. This PR simply adds a default time limit of 2 minutes - at which point an error will be produced. This should allow us to more easily find the culprit. Signed-off-by: Andrew Thornton <art27@cantab.net> * return better error 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.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/modules/queue/manager.go b/modules/queue/manager.go
index a88933191a..23e96155a9 100644
--- a/modules/queue/manager.go
+++ b/modules/queue/manager.go
@@ -9,6 +9,7 @@ import (
"fmt"
"reflect"
"sort"
+ "strings"
"sync"
"time"
@@ -169,7 +170,17 @@ func (m *Manager) FlushAll(baseCtx context.Context, timeout time.Duration) error
for {
select {
case <-ctx.Done():
- return ctx.Err()
+ mqs := m.ManagedQueues()
+ nonEmptyQueues := []string{}
+ for _, mq := range mqs {
+ if !mq.IsEmpty() {
+ nonEmptyQueues = append(nonEmptyQueues, mq.Name)
+ }
+ }
+ if len(nonEmptyQueues) > 0 {
+ return fmt.Errorf("flush timeout with non-empty queues: %s", strings.Join(nonEmptyQueues, ", "))
+ }
+ return nil
default:
}
mqs := m.ManagedQueues()