Skip to content

Commit c279f8a

Browse files
authored
Fix incorrect ctx usage in defer function (#27740) (#27741)
1 parent 9f2b8c7 commit c279f8a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

services/task/migrate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func handleCreateError(owner *user_model.User, err error) error {
4242
}
4343

4444
func runMigrateTask(ctx context.Context, t *admin_model.Task) (err error) {
45-
defer func() {
45+
defer func(ctx context.Context) {
4646
if e := recover(); e != nil {
4747
err = fmt.Errorf("PANIC whilst trying to do migrate task: %v", e)
4848
log.Critical("PANIC during runMigrateTask[%d] by DoerID[%d] to RepoID[%d] for OwnerID[%d]: %v\nStacktrace: %v", t.ID, t.DoerID, t.RepoID, t.OwnerID, e, log.Stack(2))
@@ -69,7 +69,7 @@ func runMigrateTask(ctx context.Context, t *admin_model.Task) (err error) {
6969
}
7070

7171
// then, do not delete the repository, otherwise the users won't be able to see the last error
72-
}()
72+
}(graceful.GetManager().ShutdownContext()) // even if the parent ctx is canceled, this defer-function still needs to update the task record in database
7373

7474
if err = t.LoadRepo(ctx); err != nil {
7575
return err

0 commit comments

Comments
 (0)