fix(hostlimit): an urgent cut on the static fallback is not rate-paced; a pacing error names the limiter

On a full or unusable --host-limit-dir only urgent work (the seal at stop)
runs, on the static fallback. Pacing it at BytesPerSecond/FallbackVolumes
(320 KiB/s by default) made detach --plain time out, reported as 'chunk
remote unavailable'. With no shared cap to protect it is not paced now, and
an upload-pacing error says so. Issue 486.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-11-23 00:53:13 -08:00
1 parent 3a79f5b212
commit 598e8f9899
4 files changed
+28 -4

No files matched your search

+1 -1
View File
@@ -15,6 +15,6 @@ func registerHostLimitFlags(fs *flag.FlagSet, c *hostlimit.Config) {
fs.Int64Var(&c.PayloadBytes, "host-limit-payload-bytes", c.PayloadBytes, "maximum cut payload per slot")
fs.Int64Var(&c.COWBytes, "host-limit-cow-bytes", c.COWBytes, "maximum saved COW bytes per slot")
fs.Int64Var(&c.BytesPerSecond, "host-limit-upload-bytes-sec", c.BytesPerSecond, "pacing parameter divided per process by cut-slot count; not a host rate cap")
fs.IntVar(&c.FallbackVolumes, "host-limit-fallback-volumes", c.FallbackVolumes, "urgent-fallback per-process divisor; coordinated host cap is not enforced")
fs.IntVar(&c.FallbackVolumes, "host-limit-fallback-volumes", c.FallbackVolumes, "kept for configuration compatibility; the urgent fallback is not paced (no shared host cap to protect)")
fs.DurationVar(&c.MaxHold, "host-limit-max-hold", c.MaxHold, "cut lease timeout; expiration aborts but waits for admitted I/O before release")
}
@@ -584,7 +584,7 @@ func (r *closeBoundRemote) Put(ctx context.Context, key string, data []byte) err
defer end()
if r.waitUpload != nil {
if err := r.waitUpload(c, len(data)); err != nil {
return err
return fmt.Errorf("hostlimit: upload pacing before put %s: %w", key, err)
}
}
return r.ChunkRemote.Put(c, key, data)
+5 -2
View File
@@ -469,10 +469,13 @@ func (l *Limiter) WaitUpload(ctx context.Context, n int) error {
l.mu.Unlock()
return ErrRevoked
}
div := l.cfg.NormalSlots + l.cfg.UrgentSlots
if l.fallback {
div = l.cfg.FallbackVolumes
// Only an urgent cut runs on the fallback, and with the shared
// pool unusable there is no host cap to protect: not paced.
l.mu.Unlock()
return nil
}
div := l.cfg.NormalSlots + l.cfg.UrgentSlots
rate := l.cfg.BytesPerSecond / int64(div)
if rate < 1 {
rate = 1
@@ -635,3 +635,24 @@ func TestAdmitClosedDuringPoolAcquisitionIsRevoked(t *testing.T) {
t.Fatalf("admission racing Close: id=%d err=%v; want ErrRevoked", id, err)
}
}
// An urgent cut on the static fallback (the shared pool is unusable) is not
// rate-paced: there is no shared cap to protect, and pacing it at
// BytesPerSecond/FallbackVolumes made a seal time out (issue 486).
func TestUrgentFallbackUploadIsNotPaced(t *testing.T) {
c := testConfig(t)
c.Directory += "-missing"
l := newTest(t, c)
id, err := l.Acquire(context.Background(), Urgent, nil)
if err != nil || !l.Snapshot().(Stats).FallbackActive {
t.Fatalf("urgent fallback: id=%d err=%v", id, err)
}
defer l.Release(id)
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
for i := 0; i < 4; i++ {
if err := l.WaitUpload(ctx, 16<<20); err != nil {
t.Fatalf("upload %d on the fallback was paced: %v", i, err)
}
}
}