fix(evolution): add ok check for LoadOrStore type assertion in lockStoreFile

This commit is contained in:
程智超0668000959
2026-06-08 16:47:53 +08:00
parent b9a8fad6fa
commit f5add27d39
+10 -1
View File
@@ -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
}