From a24a51e3fa3de102a6f86affa76b5fe97fe7b1fc Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 23 Aug 2025 19:30:54 -0700 Subject: [PATCH] Update weed/topology/node.go Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- weed/topology/node.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/weed/topology/node.go b/weed/topology/node.go index 208244d00..cb526f59d 100644 --- a/weed/topology/node.go +++ b/weed/topology/node.go @@ -95,13 +95,14 @@ func (cr *CapacityReservations) tryReserveAtomic(diskType types.DiskType, count if availableSpace >= count { // Create and add reservation atomically - reservationId = fmt.Sprintf("%s-%d-%d-%d", diskType, count, time.Now().UnixNano(), rand.Int64()) - cr.reservations[reservationId] = &CapacityReservation{ - reservationId: reservationId, - diskType: diskType, - count: count, - createdAt: time.Now(), - } + now := time.Now() + reservationId = fmt.Sprintf("%s-%d-%d-%d", diskType, count, now.UnixNano(), rand.Int64()) + cr.reservations[reservationId] = &CapacityReservation{ + reservationId: reservationId, + diskType: diskType, + count: count, + createdAt: now, + } cr.reservedCounts[diskType] += count return reservationId, true }