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 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-12-02 16:27:18 -08:00
1 parent 2ffd040f1e
commit c40e01786b
1 file changed
+4 -4
+4 -4
View File
@@ -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
}