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 }