From c40e01786b34bd8019d0bb54f8f019cf9150ee2f Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 2 Dec 2026 16:27:18 -0800 Subject: [PATCH] master: charge assigned bytes only once the file id is recorded An assignment that failed to record its file ids kept the bytes charged to the volume, which could mark a volume near its limit full for an upload that never came. Co-Authored-By: Claude Opus 5.5 --- weed/topology/topology.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/weed/topology/topology.go b/weed/topology/topology.go index 47cb6d795b..812af142bc 100644 --- a/weed/topology/topology.go +++ b/weed/topology/topology.go @@ -731,6 +731,10 @@ func (t *Topology) PickForWrite(requestedCount uint64, option *VolumeGrowOption, if volumeLocationList == nil || volumeLocationList.Length() == 0 { return "", 0, nil, shouldGrow, fmt.Errorf("%s available for collection:%s replication:%s ttl:%s", NoWritableVolumes, option.Collection, option.ReplicaPlacement.String(), option.Ttl.String()) } + nextFileId, err := t.nextFileId(requestedCount) + if err != nil { + return "", 0, nil, shouldGrow, fmt.Errorf("record file ids as handed out: %w", err) + } // Track estimated assigned bytes to spread load between heartbeats. A flat // fallback overcharges a small-file workload enough to mark near-empty // volumes full, so prefer the volume's own average. @@ -746,10 +750,6 @@ func (t *Topology) PickForWrite(requestedCount uint64, option *VolumeGrowOption, if volumeLayout.RecordAssign(vid, int64(pendingBytes)) { volumeLayout.AdjustActiveVolumeCountForFull(vid) } - nextFileId, err := t.nextFileId(requestedCount) - if err != nil { - return "", 0, nil, shouldGrow, fmt.Errorf("record file ids as handed out: %w", err) - } fileId = needle.NewFileId(vid, nextFileId, rand.Uint32()).String() return fileId, count, volumeLocationList, shouldGrow, nil }