]> source.dussan.org Git - gitea.git/commitdiff
Fix incorrect run order of action jobs (#28367)
authoryp05327 <576951401@qq.com>
Wed, 6 Dec 2023 22:10:05 +0000 (07:10 +0900)
committerGitHub <noreply@github.com>
Wed, 6 Dec 2023 22:10:05 +0000 (22:10 +0000)
When we pick up a job, all waiting jobs should firstly be ordered by
update time,
otherwise when there's a running job, if I rerun an older job, the older
job will run first, as it's id is smaller.

models/actions/task.go

index db0031b3b8d3c1fb7d60ad846a65da61ea9785ec..96a6d2e80ca7fcaff2ef8006370ce01db2d0c16d 100644 (file)
@@ -234,7 +234,7 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
        }
 
        var jobs []*ActionRunJob
-       if err := e.Where("task_id=? AND status=?", 0, StatusWaiting).And(jobCond).Asc("id").Find(&jobs); err != nil {
+       if err := e.Where("task_id=? AND status=?", 0, StatusWaiting).And(jobCond).Asc("updated", "id").Find(&jobs); err != nil {
                return nil, false, err
        }