From 87aa552531c7845d7d82b004490e48f6aa80e85a Mon Sep 17 00:00:00 2001 From: CaiCandong <50507092+CaiCandong@users.noreply.github.com> Date: Sun, 1 Oct 2023 20:04:35 +0800 Subject: [PATCH] Fix unexpected context canceled when migrating repository (#27368) Fix #27363 Regression of #27089 --- services/task/migrate.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/task/migrate.go b/services/task/migrate.go index 70e5abdee6..b74e024ba6 100644 --- a/services/task/migrate.go +++ b/services/task/migrate.go @@ -47,11 +47,11 @@ func runMigrateTask(ctx context.Context, t *admin_model.Task) (err error) { err = fmt.Errorf("PANIC whilst trying to do migrate task: %v", e) 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)) } - + // fixme: Because ctx is canceled here, so the db.DefaultContext is needed. if err == nil { - err = admin_model.FinishMigrateTask(ctx, t) + err = admin_model.FinishMigrateTask(db.DefaultContext, t) if err == nil { - notify_service.MigrateRepository(ctx, t.Doer, t.Owner, t.Repo) + notify_service.MigrateRepository(db.DefaultContext, t.Doer, t.Owner, t.Repo) return } @@ -63,8 +63,8 @@ func runMigrateTask(ctx context.Context, t *admin_model.Task) (err error) { t.EndTime = timeutil.TimeStampNow() t.Status = structs.TaskStatusFailed t.Message = err.Error() - - if err := t.UpdateCols(ctx, "status", "message", "end_time"); err != nil { + // fixme: Because ctx is canceled here, so the db.DefaultContext is needed. + if err := t.UpdateCols(db.DefaultContext, "status", "message", "end_time"); err != nil { log.Error("Task UpdateCols failed: %v", err) }