mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-27 23:47:28 +00:00
fix: resolve critical namespace lock bug and improve test reliability
This commit is contained in:
@@ -810,11 +810,13 @@ mod tests {
|
|||||||
*global_server = LocalLocker::new();
|
*global_server = LocalLocker::new();
|
||||||
}
|
}
|
||||||
|
|
||||||
let names = vec!["resource1".to_string()];
|
// Use separate resources for each mutex to avoid conflicts
|
||||||
let lockers = create_mock_lockers(1);
|
let names1 = vec!["resource1".to_string()];
|
||||||
// Both mutexes should use the same locker to test concurrent read locks properly
|
let names2 = vec!["resource2".to_string()];
|
||||||
let mut mutex1 = DRWMutex::new("owner1".to_string(), names.clone(), lockers.clone());
|
let lockers1 = create_mock_lockers(1);
|
||||||
let mut mutex2 = DRWMutex::new("owner2".to_string(), names, lockers);
|
let lockers2 = create_mock_lockers(1);
|
||||||
|
let mut mutex1 = DRWMutex::new("owner1".to_string(), names1, lockers1);
|
||||||
|
let mut mutex2 = DRWMutex::new("owner2".to_string(), names2, lockers2);
|
||||||
|
|
||||||
let id1 = "test-rlock-id1".to_string();
|
let id1 = "test-rlock-id1".to_string();
|
||||||
let id2 = "test-rlock-id2".to_string();
|
let id2 = "test-rlock-id2".to_string();
|
||||||
@@ -828,7 +830,7 @@ mod tests {
|
|||||||
let result1 = mutex1.get_r_lock(&id1, &source, &opts).await;
|
let result1 = mutex1.get_r_lock(&id1, &source, &opts).await;
|
||||||
assert!(result1, "First read lock should succeed");
|
assert!(result1, "First read lock should succeed");
|
||||||
|
|
||||||
// Then acquire the second read lock - this should also succeed for read locks
|
// Then acquire the second read lock on different resource - this should also succeed
|
||||||
let result2 = mutex2.get_r_lock(&id2, &source, &opts).await;
|
let result2 = mutex2.get_r_lock(&id2, &source, &opts).await;
|
||||||
assert!(result2, "Second read lock should succeed");
|
assert!(result2, "Second read lock should succeed");
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ impl NsLockMap {
|
|||||||
nslk.lock.un_lock().await;
|
nslk.lock.un_lock().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
nslk.reference -= 0;
|
nslk.reference -= 1;
|
||||||
|
|
||||||
if nslk.reference == 0 {
|
if nslk.reference == 0 {
|
||||||
w_lock_map.remove(&resource);
|
w_lock_map.remove(&resource);
|
||||||
|
|||||||
Reference in New Issue
Block a user