summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-02-08 14:02:32 +0000
committerGitHub <noreply@github.com>2022-02-08 14:02:32 +0000
commitdf4401732825b9b378e51663d74edb795446f2d3 (patch)
tree645acf249857f7cc8d279d9ba1148c4b1a7efe62 /services
parent4d939845d20d377e06bce5b02667ff21f69c3beb (diff)
downloadgitea-df4401732825b9b378e51663d74edb795446f2d3.tar.gz
gitea-df4401732825b9b378e51663d74edb795446f2d3.zip
Restart zero worker if there is still work to do (#18658)
* Restart zero worker if there is still work to do It is possible for the zero worker to timeout before all the work is finished. This may mean that work may take a long time to complete because a worker will only be induced on repushing. Also ensure that requested count is reset after pulls and push mirror sync requests and add some more trace logging to the queue push. Fix #18607 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'services')
-rw-r--r--services/mirror/mirror.go28
1 files changed, 18 insertions, 10 deletions
diff --git a/services/mirror/mirror.go b/services/mirror/mirror.go
index 6f285ec467..5639a08f96 100644
--- a/services/mirror/mirror.go
+++ b/services/mirror/mirror.go
@@ -59,11 +59,13 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
handler := func(idx int, bean interface{}, limit int) error {
var item SyncRequest
+ var repo *repo_model.Repository
if m, ok := bean.(*repo_model.Mirror); ok {
if m.Repo == nil {
log.Error("Disconnected mirror found: %d", m.ID)
return nil
}
+ repo = m.Repo
item = SyncRequest{
Type: PullMirrorType,
RepoID: m.RepoID,
@@ -73,6 +75,7 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
log.Error("Disconnected push-mirror found: %d", m.ID)
return nil
}
+ repo = m.Repo
item = SyncRequest{
Type: PushMirrorType,
RepoID: m.RepoID,
@@ -89,17 +92,16 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
default:
}
- // Check if this request is already in the queue
- has, err := mirrorQueue.Has(&item)
- if err != nil {
- return err
- }
- if has {
- return nil
- }
-
// Push to the Queue
if err := mirrorQueue.Push(&item); err != nil {
+ if err == queue.ErrAlreadyInQueue {
+ if item.Type == PushMirrorType {
+ log.Trace("PushMirrors for %-v already queued for sync", repo)
+ } else {
+ log.Trace("PullMirrors for %-v already queued for sync", repo)
+ }
+ return nil
+ }
return err
}
@@ -110,23 +112,29 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
return nil
}
+ pullMirrorsRequested := 0
if pullLimit != 0 {
+ requested = 0
if err := repo_model.MirrorsIterate(func(idx int, bean interface{}) error {
return handler(idx, bean, pullLimit)
}); err != nil && err != errLimit {
log.Error("MirrorsIterate: %v", err)
return err
}
+ pullMirrorsRequested, requested = requested, 0
}
+ pushMirrorsRequested := 0
if pushLimit != 0 {
+ requested = 0
if err := repo_model.PushMirrorsIterate(func(idx int, bean interface{}) error {
return handler(idx, bean, pushLimit)
}); err != nil && err != errLimit {
log.Error("PushMirrorsIterate: %v", err)
return err
}
+ pushMirrorsRequested, requested = requested, 0
}
- log.Trace("Finished: Update")
+ log.Trace("Finished: Update: %d pull mirrors and %d push mirrors queued", pullMirrorsRequested, pushMirrorsRequested)
return nil
}