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:
Krishnan Parthasarathi 2018-01-17 01:30:12 +05:30 committed by kannappanr
parent aa7e5c71e9
commit 17301fe45d
2 changed files with 30 additions and 2 deletions

View File

@ -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()

View File

@ -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)
}
}