You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ly...@apache.org on 2024/06/19 10:52:38 UTC

(incubator-devlake) branch release-v1.0 updated: fix(migration): fix unexpected `defer unlock` (#7634) (#7635)

This is an automated email from the ASF dual-hosted git repository.

lynwee pushed a commit to branch release-v1.0
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/release-v1.0 by this push:
     new 637eab058 fix(migration): fix unexpected `defer unlock` (#7634) (#7635)
637eab058 is described below

commit 637eab058c87fde0853c35d2d2b9ac70416aed4c
Author: github-actions[bot] <41...@users.noreply.github.com>
AuthorDate: Wed Jun 19 18:52:32 2024 +0800

    fix(migration): fix unexpected `defer unlock` (#7634) (#7635)
    
    Co-authored-by: Lynwee <li...@merico.dev>
---
 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 3f42efebd..3a99c02e3 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
 }