Update volume_growth_reservation_test.go
This commit is contained in:
@@ -81,14 +81,15 @@ func TestVolumeGrowth_ReservationBasedAllocation(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Simulate successful volume creation
|
// Simulate successful volume creation
|
||||||
// Must acquire lock before accessing children map to prevent race condition
|
// Acquire lock briefly to access children map, then release before updating
|
||||||
dn.Lock()
|
dn.RLock()
|
||||||
disk := dn.children[NodeId(types.HardDriveType.String())].(*Disk)
|
disk := dn.children[NodeId(types.HardDriveType.String())].(*Disk)
|
||||||
|
dn.RUnlock()
|
||||||
|
|
||||||
deltaDiskUsage := &DiskUsageCounts{
|
deltaDiskUsage := &DiskUsageCounts{
|
||||||
volumeCount: 1,
|
volumeCount: 1,
|
||||||
}
|
}
|
||||||
disk.UpAdjustDiskUsageDelta(types.HardDriveType, deltaDiskUsage)
|
disk.UpAdjustDiskUsageDelta(types.HardDriveType, deltaDiskUsage)
|
||||||
dn.Unlock()
|
|
||||||
|
|
||||||
// Release reservation after successful creation
|
// Release reservation after successful creation
|
||||||
reservation.releaseAllReservations()
|
reservation.releaseAllReservations()
|
||||||
@@ -156,14 +157,15 @@ func TestVolumeGrowth_ConcurrentAllocationPreventsRaceCondition(t *testing.T) {
|
|||||||
// Simulate completion: increment volume count BEFORE releasing reservation
|
// Simulate completion: increment volume count BEFORE releasing reservation
|
||||||
if reservation != nil {
|
if reservation != nil {
|
||||||
// First, increment the volume count to reflect the created volume
|
// First, increment the volume count to reflect the created volume
|
||||||
// Must acquire lock before accessing children map to prevent race condition
|
// Acquire lock briefly to access children map, then release before updating
|
||||||
dn.Lock()
|
dn.RLock()
|
||||||
disk := dn.children[NodeId(types.HardDriveType.String())].(*Disk)
|
disk := dn.children[NodeId(types.HardDriveType.String())].(*Disk)
|
||||||
|
dn.RUnlock()
|
||||||
|
|
||||||
deltaDiskUsage := &DiskUsageCounts{
|
deltaDiskUsage := &DiskUsageCounts{
|
||||||
volumeCount: 1,
|
volumeCount: 1,
|
||||||
}
|
}
|
||||||
disk.UpAdjustDiskUsageDelta(types.HardDriveType, deltaDiskUsage)
|
disk.UpAdjustDiskUsageDelta(types.HardDriveType, deltaDiskUsage)
|
||||||
dn.Unlock()
|
|
||||||
|
|
||||||
// Then release the reservation
|
// Then release the reservation
|
||||||
reservation.releaseAllReservations()
|
reservation.releaseAllReservations()
|
||||||
|
|||||||
Reference in New Issue
Block a user