From 637eab058c87fde0853c35d2d2b9ac70416aed4c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 18:52:32 +0800 Subject: [PATCH] fix(migration): fix unexpected `defer unlock` (#7634) (#7635) Co-authored-by: Lynwee --- backend/server/services/init.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/server/services/init.go b/backend/server/services/init.go index 3f42efebdff..3a99c02e34f 100644 --- a/backend/server/services/init.go +++ b/backend/server/services/init.go @@ -123,11 +123,12 @@ var statusLock sync.Mutex // This might be called concurrently across multiple API requests func ExecuteMigration() errors.Error { statusLock.Lock() - defer statusLock.Unlock() if serviceStatus == SERVICE_STATUS_MIGRATING { + statusLock.Unlock() return errors.BadInput.New("already migrating") } if serviceStatus == SERVICE_STATUS_READY { + statusLock.Unlock() return nil } serviceStatus = SERVICE_STATUS_MIGRATING @@ -147,6 +148,7 @@ func ExecuteMigration() errors.Error { pipelineServiceInit() statusLock.Lock() serviceStatus = SERVICE_STATUS_READY + statusLock.Unlock() return nil }