Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

Update volume_growth_reservation_test.go

chrislu30e8133524b2
diff --git a/weed/topology/volume_growth_reservation_test.go b/weed/topology/volume_growth_reservation_test.go
index 1f545b9bb9..e65d7c6185 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()