From f5add27d39838d8b363ecd82a4d95a5aa5a7987d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E6=99=BA=E8=B6=850668000959?= Date: Mon, 8 Jun 2026 16:47:53 +0800 Subject: [PATCH] fix(evolution): add ok check for LoadOrStore type assertion in lockStoreFile --- pkg/evolution/store.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/evolution/store.go b/pkg/evolution/store.go index 2e789079..d8411076 100644 --- a/pkg/evolution/store.go +++ b/pkg/evolution/store.go @@ -555,7 +555,16 @@ func isInvalidJSON(err error) bool { func lockStoreFile(path string) func() { actual, _ := storeFileLocks.LoadOrStore(path, &sync.Mutex{}) - mu := actual.(*sync.Mutex) + mu, ok := actual.(*sync.Mutex) + if !ok { + // Delete the corrupted entry so that the next LoadOrStore + // atomically creates a fresh mutex. Multiple goroutines may + // race to Delete, but LoadOrStore ensures they all converge + // on the same mutex before entering the critical section. + storeFileLocks.Delete(path) + actual, _ = storeFileLocks.LoadOrStore(path, &sync.Mutex{}) + mu = actual.(*sync.Mutex) + } mu.Lock() return mu.Unlock }