diff --git a/cmd/lock-instrument.go b/cmd/lock-instrument.go index bb560a12d..e21563b86 100644 --- a/cmd/lock-instrument.go +++ b/cmd/lock-instrument.go @@ -201,8 +201,6 @@ func (n *nsLockMap) statusBlockedToNone(param nsParam, lockSource, opsID string, if lockInfo.status != blockedStatus { 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. n.counters.lockTimedOut() diff --git a/cmd/lock-instrument_test.go b/cmd/lock-instrument_test.go index 99892ed97..9401657d8 100644 --- a/cmd/lock-instrument_test.go +++ b/cmd/lock-instrument_test.go @@ -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) } } + +// 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) + } + +}