From e8c9cf588ce20328a60bc0d46e5e9b15229ff78f Mon Sep 17 00:00:00 2001 From: Catherine Date: Thu, 4 Dec 2025 01:08:36 +0000 Subject: [PATCH] Drop the shared manifest lock in the FS backend. On Linux and macOS, two file descriptors opened by the same process are treated as if they were different processes for the purpose of locking. --- src/backend_fs.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/backend_fs.go b/src/backend_fs.go index 3956860..d61e7de 100644 --- a/src/backend_fs.go +++ b/src/backend_fs.go @@ -11,7 +11,6 @@ import ( "os" "path/filepath" "strings" - "sync" "time" ) @@ -263,10 +262,6 @@ func (fs *FSBackend) HasAtomicCAS(ctx context.Context) bool { return fs.hasAtomicCAS } -// Right now updates aren't very common, so this lock is essentially entirely uncontended. -// If it ever becomes a bottleneck it should be replaced with a per-manifest lock. -var sharedManifestLock = sync.Mutex{} - type manifestLockGuard struct { file *os.File } @@ -282,7 +277,6 @@ func lockManifest(fs *os.Root, name string) (*manifestLockGuard, error) { file.Close() return nil, fmt.Errorf("flock(LOCK_EX): %w", err) } - sharedManifestLock.Lock() return &manifestLockGuard{file}, nil } @@ -290,7 +284,6 @@ func (guard *manifestLockGuard) Unlock() { if guard.file != nil { FileUnlock(guard.file) guard.file.Close() - sharedManifestLock.Unlock() } }