Fail if no hand-off went to a worker's later admission: the skip-window
bound applies only to those, so without one the test would pass checking
nothing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TestOneStalledTicketCostsOneSkipNotEveryHandoff failed under load with
gaps [581ms 11ms 4ms 8ms 11ms 4ms]: each worker (its own limiter) judges
the stalled ticket on its own clock, which runs only while the slot is
free, so a worker whose clock started late pays its one skip on its first
turn. The skip-window bound now applies to a worker's later admissions
only (paying the skip again); the failure prints each gap with its worker.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- TestStalledEarlierTicketIsSkipped: instead of passing within 700 ms of
the start, no attempt passes before the skip time and the first attempt
begun after it passes (a 50 ms allowance for the skip judge's clock);
the attempts' start times are printed. A loaded host's late polls no
longer fail it (1.155 s seen on CI).
- TestUrgentProceedsPastAStalledProbe: the admission runs with an outer
bound of ten hold waits (a block behind the probe would never return)
and must take at least its hold wait, instead of at most hold wait +
300 ms (1.153 s seen on CI).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TestOneStalledTicketCostsOneSkipNotEveryHandoff bounded each hand-off's
idle gap at a fixed 200 ms, which a loaded runner exceeded (295 ms). A
hand-off that paid the stalled ticket's skip idles at least the skip
window, so that is the bound now; the failure prints every gap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- hostlimit: Config.YieldAfter (S, default 5 min). ShouldYield answers yes
only for a Normal hold at least S old while another cut on the host holds
a live ticket this process has not judged stalled (dead tickets are
reaped on the way); the probe runs only once the hold is old enough and
takes no limiter lock.
- storage: a cut attempt asks at each staging batch boundary and ends with
ErrCutYielded, keeping what it staged; CutsYielded counts it, never as a
failed cut.
- durable: a yielded attempt is retried at the next poll with no backoff,
on a ticket at the back (it was admitted), counted in status (CutYields)
and not logged as a failure.
- blockvolume: --host-limit-yield-after. Invariants: INV-HOST-CUT-YIELD-001;
M7 states the rule. v1.1 notes carry it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Seams: Config.YieldAfter (S, default 5 min), Limiter.ShouldYield (never,
for now), storage.ErrCutYielded, storage.BudgetYield, ChunkLayerStats.
CutsYielded and CutScheduleStatus.CutYields.
- TestShouldYieldOnlyAfterSWithALiveWaiter: a Normal hold yields only once
it is S old and another process holds a live ticket; never a lone hold,
never before S, never an urgent hold, not for a ticket judged stalled.
Fails here: no hold ever yields.
- TestCutYieldsAtABatchBoundaryAndKeepsItsStaging: a cut whose budget asks
it to yield ends at the next staging batch boundary with ErrCutYielded,
counted as a yield, not a failure, publishes nothing, and its staged
chunks are kept for the next attempt. Fails here: the cut never yields.
- TestChunkLoop_AYieldIsRetriedAtOnceAndCountedApart: a yielded attempt is
retried at the next poll, never backed off as a failure, and status counts
it apart. Fails here: the retry came 1.1 s later.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The window's timer starts inside Admit; a first admission publishes and
syncs the host configuration, which a loaded runner can stretch to
hundreds of milliseconds. The upper bound is now measured from Admit's
return; the lower bound still from before it. The failure message prints
the admission's duration.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The fetch child keeps its release (and so the slot's file) reachable
while it lives, with forced collections before it reports HELD.
- The ended-waits test registers every release at once, and its second
half frees the other slot only once each fetch is already waiting, so
the waiting path's success is what is checked.
- The competing fetches derive from a cancellable context, and cleanup
joins them within a bound.
- Comments: one fetch polls per limiter (blockvolume makes one per
process); a configuration check in progress can add its bounded guard
wait after the context ends.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A limiter's first fetch checks the host configuration under
configuration.lock, publishing it when absent (configGuard, now shared
with cut admission): a fetch-only process with other flags gets ErrConfig.
- No blocking lock: with every slot held, one fetch per process polls
every slot each 20 ms (the others wait for its turn, within their
context). An ended wait leaves no lock request, descriptor or goroutine;
lockBlocking is removed.
- The waiting is unordered and bounded by the caller's context alone; the
docs say so instead of promising a kernel queue.
- A slot taken when the context has already ended is given back, with the
context's error.
- INV-HOST-FETCH-CAP-001, M7 and the v1.1 note state the contract.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A fetch-only start must publish and check the host configuration: a
child process with FetchSlots 2 fetches first, and a FetchSlots 1 fetch
must answer ErrConfig (fails: no configuration is published).
- Waits that end at their deadline, or by taking another slot, must leave
no goroutine or descriptor behind while their slot stays held (fails: 40
blocked lock waits remain).
- A context that ends as a slot is taken must get its error, slot given
back (fails: the slot is handed over). Seam: testFetchLocked.
- Controls: a killed child's slot is freed; a waiter passed by others ends
by its deadline (the waiting is unordered, bounded by the context).
- The same-process cap test is renamed AcrossLimiters; holdAsync joins and
releases its wait in cleanup.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- hostlimit: Config.FetchSlots (default 64, files fetch-0..N-1 in the pool).
HoldFetch takes a free slot without waiting, from the key's hash slot;
with every slot held it blocks on its hash slot (the kernel queues the
waiters) and tries the other slots every 20 ms, using whichever lock comes
first and releasing the other; its context bounds the wait, and a lock got
after that is released at once. lockBlocking on Unix and Windows.
- storage: BudgetFetch; fillOnce holds one slot across its remote read only
(a read miss and a hydrate-all fill alike); a context error on the wait is
the hydration path's pending, as before.
- blockvolume: --host-limit-fetch-slots. Invariants: INV-HOST-FETCH-CAP-001;
M7 states it. v1.1 notes carry it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Seams: Config.FetchSlots (default 64), fetchSlot (a key's hash slot),
Limiter.HoldFetch (no cap yet) and storage.BudgetFetch.
- TestHoldFetchCapHoldsAcrossProcesses: with every slot held by other
processes, a fetch waits until one is released, then takes it. Fails here.
- TestHoldFetchAWaiterThatGivesUpLeavesNoSlotHeld: a waiter past its context
returns the context's error, and a slot it gets after is released at once.
Fails here.
- TestHoldFetchTakesAnotherSlotThatFreesFirst: a waiter behind a slow holder
of its own hash slot takes another slot within one retry interval of its
release. Fails here.
- TestHoldFetchTakesAFreeSlotAtOnce: a fetch with a free slot does not wait
(holds here, must keep holding).
- TestChunkFetchHoldsAHostSlotAroundItsRemoteRead: a chunk fetch holds one
slot exactly across its remote read. Fails here: none is held.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- the cut loop: an attempt admitted on its ticket that then fails retries on
a fresh ticket at the back of the queue (the host's now), never at its
schedule's earlier due time; a failed ticket creation is a wait (no cut,
the reason in status, the next poll tries again), never an un-ticketed cut.
- the limiter: an urgent admission refused after taking its urgent-pending
hold closes the hold, so no Normal admission stays refused for it.
- tests: the new concurrent tests and the ticket tests end their workers
with a bounded join on every path, a failing assertion too.
- invariants: INV-HOST-TICKET-REENTRY-001; the urgent row names its test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- TestChunkLoop_AConsumedAttemptRetriesAtTheBack: a cut admitted on its
ticket that then fails after staging is retried on a fresh ticket at the
back. Fails here: the retry's ticket is due at the schedule's old time
(even earlier than its first one), ahead of every cut that waited.
- TestChunkLoop_NoTicketNoCut: a timer cut that cannot take a ticket must
not cut un-ticketed. Fails here: it cut twice.
- TestRefusedUrgentAdmissionReleasesItsPendingHold: an urgent admission
refused after it took its urgent-pending hold gives the hold back. Fails
here: the hold leaks, keeping Normal admissions refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The change of this PR's 22 commits, carried onto current main as one
commit (its base was 1884 commits behind). Fitted to main:
- pacing: main's rule that fallback-only leases are not paced stays; a
healthy lease is paced at the budget over the held normal and urgent
slots (this PR's rule) instead of over the configured slot count.
TestFallbackDoesNotUnpaceAHealthyLease keeps its property (a healthy
lease beside a fallback lease is paced) with a 500 ms deadline, since a
lone holder now gets the whole budget.
- the cut loop keeps main's attempted hook and afterStaging (a failed
attempt that staged new chunks retries at the next poll), with the
ticket handling; the random retry delay is gone, as this PR intends.
- imports and constants: neither side's removed ones return.
- invariants: main's new rows and this PR's new and restated rows; the
slot-wait row is this PR's (ticket order, the next poll).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- expire decides and revokes in one step under the limiter's lock, reading
the last progress at that step: a progress report that completed before it
is always honoured.
- Progress takes no lock: it reads a lease index (sync.Map, kept with the
live set) and stores an atomic stamp, so it never waits behind an
admission's file-system work.
- the window runs on the monotonic clock: a stamp is time.Since of the
limiter's base, never a wall timestamp.
- the launch refusal of a pool written with other flags names
configuration.json and the cure (stop every process, remove it, start);
the v1.1 notes carry the hold change and the upgrade step; the upload
rate flag says the window must exceed one chunk's send time at it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Seam: testExpireRace, run between a hold's expiry decision and its
revocation.
- TestProgressRacingTheExpiryIsHonoured: a progress report landing while
the expiry is decided must be honoured. Fails here: the decision is made,
the lock dropped, and the hold revoked anyway.
- TestProgressDoesNotWaitForTheLimiterLock: Progress must not wait for the
limiter's lock, which admission holds across file-system work. Fails
here: it takes that lock.
- TestProgressStampIsMonotonicElapsed: the progress stamp must be an
elapsed time on the limiter's monotonic base. Fails here: a wall-clock
timestamp, so a clock step revokes or keeps holds wrongly.
- TestLaunchMismatchNamesTheFileAndTheCure: the launch refusal of a pool
written with other flags must name configuration.json and the cure
(stop every process, remove the file). Fails here.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- hostlimit: Config.MaxHold (a fixed 5-minute hold limit) becomes
NoProgress (default 60 s). Progress(id) records the work's progress, with
no OS call; the hold's one timer, when it fires, arms again for the rest
of the window if the work progressed, and revokes otherwise. A hold whose
work keeps progressing is never revoked; a stalled one is revoked within
the window.
- blockvolume: --host-limit-no-progress; --host-limit-max-hold stays as a
deprecated alias of it.
- storage: BudgetProgress, the optional Budget that renews a hold; a cut
attempt reports one unit of work per chunk compared, staged or uploaded.
A hydrate-all holds one permit per chunk fill, so its hold is one fetch.
- invariants: INV-HOST-HOLD-NO-PROGRESS-001; M7 states the rule.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Seams: Config.NoProgress (default 60 s), Limiter.Progress (a no-op for
now) and storage.BudgetProgress, the optional Budget that renews a hold.
- TestStalledHoldIsRevokedWithinTheWindow: a hold with no progress is
revoked within its no-progress window. Fails here: the fixed 5-minute
hold limit still governs.
- TestProgressRenewsTheHold: a hold whose work keeps progressing is never
revoked; once the progress stops, it is revoked within the window. Fails
here on the second half.
- TestCutReportsProgressToItsBudget: a cut reports progress at least once
per uploaded chunk. Fails here: no report. (A hydrate-all takes one permit
per chunk fill, so its hold is one fetch and needs no renewal.)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A healthy lease admitted beside an urgent fallback lease kept no pacing
(review). The pacing error wrapper now has a test: prefix, cause, no put.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
- The provider tests wrap the real limiter and record every Admit call
with its time and outcome. Retry gaps are measured between recorded
held-slot refusals, and the first admission after the slot frees is
timed from the release (<= 400 ms); publication is bounded separately.
- The close-race control bounds its wait for Close and joins it from a
cleanup registered before the goroutine starts.
- Wording: a shorter delay range makes a late volume likely, not certain,
to retry first; the seeded one-slot simulation is a regression check,
not a proof of the bound.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A pool file, urgent-pending, signals urgent work on the host. An
urgent cut holds it shared for its lease, and HoldUrgentPending lets a
caller hold it across a stop or a drain. A Normal admission probes it
exclusively without waiting and, while it is held, is refused with
ErrUrgentPending (an ErrSlotsHeld, so the timer waits instead of
failing). Urgent admissions are unaffected.
- blockvolume checks --host-limit-dir before using it and refuses to
start when it is missing or not a directory, under a temporary
directory (/tmp, /var/tmp, /dev/shm, the process temp dir), on a
network file system (NFS, CIFS, SMB2, FUSE on Linux), or already in
use with different host-limit flags.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Status ends a recorded host slot wait once the layer's CutSeq moves
past the one it was recorded under, so a detach's seal (made after the
timer stopped) or an explicit cut clears it; the count is kept.
- A successful cut observed during a slot wait also drops the pending
slot retry.
- Admission that finds the limiter closed after acquiring its pool slot
returns ErrRevoked, not ErrSlotsHeld.
- The provider test witnesses every refused attempt with a timestamp
(at least 8 in 2.5 s, none more than 400 ms apart), then bounds the
admission after the slot frees (400 ms) and publication (5 s)
separately.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A periodic cut refused because every host cut slot is held must be a
wait, not a failure: no backoff, retry after the volume's jitter, and
the wait reported in status. The types the tests name are added; the
behaviour is not.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>