From 1e85c14d7e8d7aee1fad62d11e857cf53bc0a720 Mon Sep 17 00:00:00 2001 From: Lynwee Date: Wed, 19 Jun 2024 18:48:19 +0800 Subject: [PATCH] fix(migration): fix unexpected `defer unlock` (#7634) --- 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 07b565fb76d..ce07bea65f1 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 @@ -146,6 +147,7 @@ func ExecuteMigration() errors.Error { pipelineServiceInit() statusLock.Lock() serviceStatus = SERVICE_STATUS_READY + statusLock.Unlock() return nil }