Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

Fix stale admin lock metric when lock expires and is reacquired (#8859)

Chris Lu4705d8b82b08
diff --git a/weed/server/master_grpc_server_admin.go b/weed/server/master_grpc_server_admin.go
index eb6cb452bc..ce90f5cace 100644
--- a/weed/server/master_grpc_server_admin.go
+++ b/weed/server/master_grpc_server_admin.go
@@ -106,6 +106,9 @@ func (locks *AdminLocks) isValidToken(lockName string, ts time.Time, token int64
func (locks *AdminLocks) generateToken(lockName string, clientName string) (ts time.Time, token int64) {
locks.Lock()
defer locks.Unlock()
+ if existing, found := locks.locks[lockName]; found && existing.lastClient != clientName {
+ stats.MasterAdminLock.DeleteLabelValues(existing.lastClient)
+ }
lock := &AdminLock{
accessSecret: rand.Int64(),
accessLockTime: time.Now(),
@@ -118,7 +121,7 @@ func (locks *AdminLocks) generateToken(lockName string, clientName string) (ts t
func (locks *AdminLocks) deleteLock(lockName string) {
locks.Lock()
- stats.MasterAdminLock.WithLabelValues(locks.locks[lockName].lastClient).Set(0)
+ stats.MasterAdminLock.DeleteLabelValues(locks.locks[lockName].lastClient)
defer locks.Unlock()
delete(locks.locks, lockName)
}