mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-07 15:32:11 +00:00
fix(actions): write an action task report in one transaction (#38792)
`UpdateTaskByState` wrote the task, its job and its steps in separate statements. An interruption in between left the task finished with a running job, so the run stayed in progress, and the "state is final" early return made every retry, cancel and cleanup a no-op. Fixes https://github.com/go-gitea/gitea/issues/38790
This commit is contained in:
@@ -487,7 +487,7 @@ func UpdateTaskByState(ctx context.Context, runnerID int64, state *runnerv1.Task
|
||||
return nil, err
|
||||
}
|
||||
task := &ActionTask{}
|
||||
err = globallock.LockAndDo(ctx, fmt.Sprintf("UpdateTaskByState-run-%d", runID), func(ctx context.Context) error {
|
||||
applyState := func(ctx context.Context) error {
|
||||
if has, err := db.GetEngine(ctx).ID(taskID).Get(task); err != nil {
|
||||
return err
|
||||
} else if !has {
|
||||
@@ -552,6 +552,10 @@ func UpdateTaskByState(ctx context.Context, runnerID int64, state *runnerv1.Task
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
err = globallock.LockAndDo(ctx, fmt.Sprintf("UpdateTaskByState-run-%d", runID), func(ctx context.Context) error {
|
||||
// A half-written report leaves the task done with a running job, which no retry repairs.
|
||||
return db.WithTx(ctx, applyState)
|
||||
})
|
||||
return task, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user