mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
Don't delete lock ops entry during state change (#5388)
lock ops entry is removed in deleteLockEntryForOps, it shouldn't be removed in status*To* functions.
This commit is contained in:
parent
aa7e5c71e9
commit
17301fe45d
@ -201,8 +201,6 @@ func (n *nsLockMap) statusBlockedToNone(param nsParam, lockSource, opsID string,
|
|||||||
if lockInfo.status != blockedStatus {
|
if lockInfo.status != blockedStatus {
|
||||||
return errors.Trace(LockInfoStateNotBlocked{param.volume, param.path, opsID})
|
return errors.Trace(LockInfoStateNotBlocked{param.volume, param.path, opsID})
|
||||||
}
|
}
|
||||||
// Clear the status by removing the entry for the given `opsID`.
|
|
||||||
delete(n.debugLockMap[param].lockInfo, opsID)
|
|
||||||
|
|
||||||
// Update global lock stats.
|
// Update global lock stats.
|
||||||
n.counters.lockTimedOut()
|
n.counters.lockTimedOut()
|
||||||
|
@ -637,3 +637,33 @@ func TestNsLockMapDeleteLockInfoEntryForVolumePath(t *testing.T) {
|
|||||||
t.Errorf("Expected the count of all locks to be %v, but got %v", 0, globalNSMutex.counters.total)
|
t.Errorf("Expected the count of all locks to be %v, but got %v", 0, globalNSMutex.counters.total)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test to assert that status change from blocked to none shouldn't remove lock info entry for ops
|
||||||
|
// Ref: Logs from https://github.com/minio/minio/issues/5311
|
||||||
|
func TestStatusBlockedToNone(t *testing.T) {
|
||||||
|
// Initialize namespace lock subsystem
|
||||||
|
initNSLock(false)
|
||||||
|
|
||||||
|
ns := globalNSMutex
|
||||||
|
|
||||||
|
volume, path := "bucket", "object"
|
||||||
|
param := nsParam{volume: volume, path: path}
|
||||||
|
lockSrc := "main.go:1"
|
||||||
|
opsID := "1"
|
||||||
|
|
||||||
|
err := ns.statusNoneToBlocked(param, lockSrc, opsID, false)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal("Failed to mark lock state to blocked")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ns.statusBlockedToNone(param, lockSrc, opsID, false)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal("Failed to mark lock state to none")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ns.deleteLockInfoEntryForOps(param, opsID)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Expected deleting of lock entry for %s to pass but got %v", opsID, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user