From e2f889192c54e8bfd14760a56439c215f04edaba Mon Sep 17 00:00:00 2001 From: d4x1 <1507509064@qq.com> Date: Wed, 19 Jun 2024 18:26:21 +0800 Subject: [PATCH] fix(migration): fix unexpected `defer unlock` --- 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 }