mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
parent
ae64b7fac8
commit
37cbcae6ba
@ -88,7 +88,7 @@ func (s *TestRPCControllerSuite) TestRPCControlLock(c *C) {
|
|||||||
expectedVolPathBlockCount: 0,
|
expectedVolPathBlockCount: 0,
|
||||||
},
|
},
|
||||||
// Test case 2.
|
// Test case 2.
|
||||||
// Testing the existance of entry for the last read lock (read lock with opsID "9").
|
// Testing the existence of entry for the last read lock (read lock with opsID "9").
|
||||||
{
|
{
|
||||||
|
|
||||||
volume: "my-bucket",
|
volume: "my-bucket",
|
||||||
@ -203,11 +203,11 @@ func (s *TestRPCControllerSuite) TestRPCControlLock(c *C) {
|
|||||||
// expected lock info.
|
// expected lock info.
|
||||||
expectedLockStats := expectedResult[0]
|
expectedLockStats := expectedResult[0]
|
||||||
// verify the actual lock info with the expected one.
|
// verify the actual lock info with the expected one.
|
||||||
// verify the existance entry for first read lock (read lock with opsID "0").
|
// verify the existence entry for first read lock (read lock with opsID "0").
|
||||||
verifyRPCLockInfoResponse(expectedLockStats, *reply, c, 1)
|
verifyRPCLockInfoResponse(expectedLockStats, *reply, c, 1)
|
||||||
expectedLockStats = expectedResult[1]
|
expectedLockStats = expectedResult[1]
|
||||||
// verify the actual lock info with the expected one.
|
// verify the actual lock info with the expected one.
|
||||||
// verify the existance entry for last read lock (read lock with opsID "9").
|
// verify the existence entry for last read lock (read lock with opsID "9").
|
||||||
verifyRPCLockInfoResponse(expectedLockStats, *reply, c, 2)
|
verifyRPCLockInfoResponse(expectedLockStats, *reply, c, 2)
|
||||||
|
|
||||||
// now hold a write lock in a different go routine and it should block since 10 read locks are
|
// now hold a write lock in a different go routine and it should block since 10 read locks are
|
||||||
@ -256,7 +256,7 @@ func (s *TestRPCControllerSuite) TestRPCControlLock(c *C) {
|
|||||||
nsMutex.RUnlock("my-bucket", "my-object", strconv.Itoa(i))
|
nsMutex.RUnlock("my-bucket", "my-object", strconv.Itoa(i))
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
// Since all the locks are released. There shouldnt be any entry in the lock info.
|
// Since all the locks are released. There should not be any entry in the lock info.
|
||||||
// and all the counters should be set to 0.
|
// and all the counters should be set to 0.
|
||||||
reply = &SystemLockState{}
|
reply = &SystemLockState{}
|
||||||
// Call the lock instrumentation RPC end point.
|
// Call the lock instrumentation RPC end point.
|
||||||
|
@ -255,7 +255,7 @@ func (n *nsLockMap) deleteLockInfoEntryForOps(param nsParam, operationID string)
|
|||||||
// decrease the global running and lock reference counter.
|
// decrease the global running and lock reference counter.
|
||||||
n.runningLockCounter--
|
n.runningLockCounter--
|
||||||
n.globalLockCounter--
|
n.globalLockCounter--
|
||||||
// decrease the lock referene counter for the lock info for given <volume,path> pair.
|
// decrease the lock referee counter for the lock info for given <volume,path> pair.
|
||||||
// decrease the running operation number. Its assumed that the operation is over once an attempt to release the lock is made.
|
// decrease the running operation number. Its assumed that the operation is over once an attempt to release the lock is made.
|
||||||
infoMap.running--
|
infoMap.running--
|
||||||
// decrease the total reference count of locks jeld on <volume,path> pair.
|
// decrease the total reference count of locks jeld on <volume,path> pair.
|
||||||
|
@ -34,7 +34,7 @@ type lockStateCase struct {
|
|||||||
|
|
||||||
expectedGlobalLockCount int // Total number of locks held across the system, includes blocked + held locks.
|
expectedGlobalLockCount int // Total number of locks held across the system, includes blocked + held locks.
|
||||||
expectedBlockedLockCount int // Total blocked lock across the system.
|
expectedBlockedLockCount int // Total blocked lock across the system.
|
||||||
expectedRunningLockCount int // Total succesfully held locks (non-blocking).
|
expectedRunningLockCount int // Total successfully held locks (non-blocking).
|
||||||
// expected lock statu for given <volume, path> pair.
|
// expected lock statu for given <volume, path> pair.
|
||||||
expectedVolPathLockCount int // Total locks held for given <volume,path> pair, includes blocked locks.
|
expectedVolPathLockCount int // Total locks held for given <volume,path> pair, includes blocked locks.
|
||||||
expectedVolPathRunningCount int // Total succcesfully held locks for given <volume, path> pair.
|
expectedVolPathRunningCount int // Total succcesfully held locks for given <volume, path> pair.
|
||||||
@ -601,7 +601,7 @@ func TestNsLockMapDeleteLockInfoEntryForOps(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Case - 3.
|
// Case - 3.
|
||||||
// Lock state is set to Running and then an attempt to delete the info for non-existant opsID done.
|
// Lock state is set to Running and then an attempt to delete the info for non-existent opsID done.
|
||||||
nsMutex.lockMapMutex.Lock()
|
nsMutex.lockMapMutex.Lock()
|
||||||
err := nsMutex.statusNoneToBlocked(param, testCases[0].lockOrigin, testCases[0].opsID, testCases[0].readLock)
|
err := nsMutex.statusNoneToBlocked(param, testCases[0].lockOrigin, testCases[0].opsID, testCases[0].readLock)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -612,9 +612,9 @@ func TestNsLockMapDeleteLockInfoEntryForOps(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Setting lock status to Running failed: <ERROR> %s", err)
|
t.Fatalf("Setting lock status to Running failed: <ERROR> %s", err)
|
||||||
}
|
}
|
||||||
actualErr = nsMutex.deleteLockInfoEntryForOps(param, "non-existant-OpsID")
|
actualErr = nsMutex.deleteLockInfoEntryForOps(param, "non-existent-OpsID")
|
||||||
|
|
||||||
expectedOpsIDErr := LockInfoOpsIDNotFound{param.volume, param.path, "non-existant-OpsID"}
|
expectedOpsIDErr := LockInfoOpsIDNotFound{param.volume, param.path, "non-existent-OpsID"}
|
||||||
if actualErr != expectedOpsIDErr {
|
if actualErr != expectedOpsIDErr {
|
||||||
t.Fatalf("Errors mismatch: Expected \"%s\", got \"%s\"", expectedOpsIDErr, actualErr)
|
t.Fatalf("Errors mismatch: Expected \"%s\", got \"%s\"", expectedOpsIDErr, actualErr)
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ func TestLockStats(t *testing.T) {
|
|||||||
},
|
},
|
||||||
// Test case - 6.
|
// Test case - 6.
|
||||||
// Case where in the first 5 read locks are released, but 2 write locks are
|
// Case where in the first 5 read locks are released, but 2 write locks are
|
||||||
// blocked waiting for the remaining 5 read locks locks to be released (10 read locks were held intially).
|
// blocked waiting for the remaining 5 read locks locks to be released (10 read locks were held initially).
|
||||||
// We check the entry for the first blocked write call here.
|
// We check the entry for the first blocked write call here.
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -30,10 +30,6 @@ func (xl xlObjects) MakeBucket(bucket string) error {
|
|||||||
if !IsValidBucketName(bucket) {
|
if !IsValidBucketName(bucket) {
|
||||||
return BucketNameInvalid{Bucket: bucket}
|
return BucketNameInvalid{Bucket: bucket}
|
||||||
}
|
}
|
||||||
// Verify if bucket is found.
|
|
||||||
if xl.isBucketExist(bucket) {
|
|
||||||
return toObjectErr(errVolumeExists, bucket)
|
|
||||||
}
|
|
||||||
|
|
||||||
// generates random string on setting MINIO_DEBUG=lock, else returns empty string.
|
// generates random string on setting MINIO_DEBUG=lock, else returns empty string.
|
||||||
// used for instrumentation on locks.
|
// used for instrumentation on locks.
|
||||||
@ -161,13 +157,6 @@ func (xl xlObjects) getBucketInfo(bucketName string) (bucketInfo BucketInfo, err
|
|||||||
|
|
||||||
// Checks whether bucket exists.
|
// Checks whether bucket exists.
|
||||||
func (xl xlObjects) isBucketExist(bucket string) bool {
|
func (xl xlObjects) isBucketExist(bucket string) bool {
|
||||||
// generates random string on setting MINIO_DEBUG=lock, else returns empty string.
|
|
||||||
// used for instrumentation on locks.
|
|
||||||
opsID := getOpsID()
|
|
||||||
|
|
||||||
nsMutex.RLock(bucket, "", opsID)
|
|
||||||
defer nsMutex.RUnlock(bucket, "", opsID)
|
|
||||||
|
|
||||||
// Check whether bucket exists.
|
// Check whether bucket exists.
|
||||||
_, err := xl.getBucketInfo(bucket)
|
_, err := xl.getBucketInfo(bucket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -261,10 +250,6 @@ func (xl xlObjects) DeleteBucket(bucket string) error {
|
|||||||
if !IsValidBucketName(bucket) {
|
if !IsValidBucketName(bucket) {
|
||||||
return BucketNameInvalid{Bucket: bucket}
|
return BucketNameInvalid{Bucket: bucket}
|
||||||
}
|
}
|
||||||
// Verify if bucket is found.
|
|
||||||
if !xl.isBucketExist(bucket) {
|
|
||||||
return BucketNotFound{Bucket: bucket}
|
|
||||||
}
|
|
||||||
|
|
||||||
// generates random string on setting MINIO_DEBUG=lock, else returns empty string.
|
// generates random string on setting MINIO_DEBUG=lock, else returns empty string.
|
||||||
// used for instrumentation on locks.
|
// used for instrumentation on locks.
|
||||||
@ -316,5 +301,7 @@ func (xl xlObjects) DeleteBucket(bucket string) error {
|
|||||||
}); reducedErr != nil {
|
}); reducedErr != nil {
|
||||||
return toObjectErr(reducedErr, bucket)
|
return toObjectErr(reducedErr, bucket)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Success.
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user