From cb9a662e20f68a8b836a4147ff4f872a80018f01 Mon Sep 17 00:00:00 2001 From: chrislu Date: Wed, 22 Oct 2025 23:37:19 -0700 Subject: [PATCH] Update volume_growth_reservation_test.go --- weed/topology/volume_growth_reservation_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/weed/topology/volume_growth_reservation_test.go b/weed/topology/volume_growth_reservation_test.go index e65d7c618..442995b80 100644 --- a/weed/topology/volume_growth_reservation_test.go +++ b/weed/topology/volume_growth_reservation_test.go @@ -139,6 +139,7 @@ func TestVolumeGrowth_ConcurrentAllocationPreventsRaceCondition(t *testing.T) { const concurrentRequests = 10 var wg sync.WaitGroup var successCount, failureCount atomic.Int32 + var commitMutex sync.Mutex // Ensures atomic commit of volume creation + reservation release for i := 0; i < concurrentRequests; i++ { wg.Add(1) @@ -156,6 +157,8 @@ func TestVolumeGrowth_ConcurrentAllocationPreventsRaceCondition(t *testing.T) { // Simulate completion: increment volume count BEFORE releasing reservation if reservation != nil { + commitMutex.Lock() + // First, increment the volume count to reflect the created volume // Acquire lock briefly to access children map, then release before updating dn.RLock() @@ -169,6 +172,8 @@ func TestVolumeGrowth_ConcurrentAllocationPreventsRaceCondition(t *testing.T) { // Then release the reservation reservation.releaseAllReservations() + + commitMutex.Unlock() } } }(i)