diff options
| author | chrislu <chris.lu@gmail.com> | 2025-10-22 21:30:13 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2025-10-22 21:30:13 -0700 |
| commit | 30e8133524b25b2e98658e8da335fa2c4586e53e (patch) | |
| tree | 3853332ce1ec6b95606908e4252d8c63fe35d1ec | |
| parent | fa025dc96f5279ad90bcff13ca67ab1a7a52db9c (diff) | |
| download | seaweedfs-30e8133524b25b2e98658e8da335fa2c4586e53e.tar.xz seaweedfs-30e8133524b25b2e98658e8da335fa2c4586e53e.zip | |
Update volume_growth_reservation_test.go
| -rw-r--r-- | weed/topology/volume_growth_reservation_test.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/weed/topology/volume_growth_reservation_test.go b/weed/topology/volume_growth_reservation_test.go index 1f545b9bb..e65d7c618 100644 --- a/weed/topology/volume_growth_reservation_test.go +++ b/weed/topology/volume_growth_reservation_test.go @@ -81,14 +81,15 @@ func TestVolumeGrowth_ReservationBasedAllocation(t *testing.T) { } // Simulate successful volume creation - // Must acquire lock before accessing children map to prevent race condition - dn.Lock() + // Acquire lock briefly to access children map, then release before updating + dn.RLock() disk := dn.children[NodeId(types.HardDriveType.String())].(*Disk) + dn.RUnlock() + deltaDiskUsage := &DiskUsageCounts{ volumeCount: 1, } disk.UpAdjustDiskUsageDelta(types.HardDriveType, deltaDiskUsage) - dn.Unlock() // Release reservation after successful creation reservation.releaseAllReservations() @@ -156,14 +157,15 @@ func TestVolumeGrowth_ConcurrentAllocationPreventsRaceCondition(t *testing.T) { // Simulate completion: increment volume count BEFORE releasing reservation if reservation != nil { // First, increment the volume count to reflect the created volume - // Must acquire lock before accessing children map to prevent race condition - dn.Lock() + // Acquire lock briefly to access children map, then release before updating + dn.RLock() disk := dn.children[NodeId(types.HardDriveType.String())].(*Disk) + dn.RUnlock() + deltaDiskUsage := &DiskUsageCounts{ volumeCount: 1, } disk.UpAdjustDiskUsageDelta(types.HardDriveType, deltaDiskUsage) - dn.Unlock() // Then release the reservation reservation.releaseAllReservations() |
