Skip to content

An idle pin is dropped by its first refusal, not by the grace (#392) - #393

Merged
superuser404notfound merged 2 commits into
mainfrom
fix/idle-pin-repin
Aug 17, 2026
Merged

superuser404notfound merged 2 commits into
mainfrom
fix/idle-pin-repin

Conversation

@superuser404notfound

Copy link
Copy Markdown
Owner

Closes #392.

The keep-pin grace answers one shape, #307's lingering slot: a connection-capped panel answers 509 while the slot of the connection this reader has just replaced is still occupied server-side. That shape requires a byte of ours to have been in flight moments ago.

A pin that has carried nothing for a minute cannot be producing it. The pump ends its connection at the window high water, so an idle reader holds nothing at the origin for a slot to linger on (#310), and what refuses there is the expired lease of #380. The grace then only delays finding out: three paced attempts against an address that will refuse every one of them, which was 12.5 s of media time in tschuegy's 6.30.0 retest, free only because 16 MB of read-ahead absorbed it. The same pause taken right after a seek is visible.

So past the idle gap the first rate-limited refusal drops the pin, and the re-resolve is not paced behind a backoff charged to the address it is no longer using (a server-sent Retry-After still applies, since the source is the same origin). A pin that is still alive pays nothing: this changes only what happens after a refusal, never how a healthy request is issued. That is why it is here rather than the stronger form the retest suggested, which would spend an idle pin through the source preemptively and pay a portal round trip on every resume, including the common one where the pin is fine.

What is in it

  • The idle clock. A wall clock stamped in addBytesFetched, i.e. at every path that crosses the network and no path that serves from memory. It has to be its own field: lastDeliveryAt is rebased by startPersistentConnection and therefore always reads as fresh at the moment a refusal is being judged. Wall time rather than uptime, because a lease expires in wall time and a device that slept through the gap has let it expire too.
  • One decision, one place. The pin rungs of both reconnect ladders were two copies of the same policy; they are now one method.
  • The detour's rate-limit arm gets the rungs too. It fetches through the same pinned target and carried none, so a pin whose lease had died could only be given up on there (a failed read), never re-resolved. It is also the arm a backward read after a long pause lands on.

Test

an idle pin is dropped by its FIRST refusal instead of riding out the grace, in the existing .serialized suite. The origin mints a numbered lease per resolve; the test lets the pump fill the window and end at the high water, then stops reading (the reader is pull-driven, so a consumer that stops is what a paused player looks like from here), arms the origin to refuse every lease minted so far, and resumes past the window's frontier so the read cannot finish until the healing request has actually delivered.

Trace from the run: one refused request against the dead lease, then one re-resolve, then served.

/cdn/movie.bin?lease=1  start=0         (pump)
/cdn/movie.bin?lease=2  start=67043328  (suffix probe)
/cdn/movie.bin?lease=1  start=16989532  -> 509
/cdn/movie.bin?lease=3  start=16989532  -> 206

The grace tests are unchanged and still assert three attempts, since their gap is nowhere near the threshold. 1928 tests in 278 suites pass.

Reported by @tschuegy in the 6.30.0 retest of #380, whose trace also answered the open question in that thread: the re-resolved target is the SAME edge host. What dies across an idle is not the address but the authorization behind it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01E5UztmCZtNYPQpzdmSdmWG

Vincent Herbst and others added 2 commits August 17, 2026 19:44
#392)

The keep-pin grace exists for one shape, #307's lingering slot: a
connection-capped panel answers 509 while the slot of the connection this
reader just replaced is still occupied server-side. That shape requires a byte
of ours to have been in flight moments ago.

A pin that has carried nothing for `pinIdleRepinSecondsDefault` cannot be
producing it. The pump ends its connection at the window high water, so an idle
reader holds nothing at the origin for a slot to linger on (#310), and what
refuses there is the expired lease of #380. The grace then only delays finding
out: three paced attempts against an address that will refuse all of them, 12.5 s
of media time in the 6.30.0 retest, free that time only because 16 MB of
read-ahead absorbed them.

So past the idle gap the first rate-limited refusal drops the pin, and the
re-resolve is not paced behind a backoff charged to the address it is no longer
using (a server-sent Retry-After still applies, since the source is the same
origin). A pin that is still alive pays nothing: this changes only what happens
after a refusal, never how a healthy request is issued.

Three supporting pieces:

- The idle clock is a wall clock stamped in `addBytesFetched`, i.e. at every
  path that crosses the network and no path that serves from memory. It has to
  be its own field: `lastDeliveryAt` is rebased by `startPersistentConnection`
  and therefore always reads as fresh when a refusal is being judged. Wall time
  rather than uptime, because a lease expires in wall time and a device that
  slept through the gap has let it expire too.
- The pin rungs of both reconnect ladders move into one method, which they were
  carrying as two copies of the same policy.
- The detour's rate-limit arm gets the same rungs. It fetches through the same
  pinned target and carried no rung at all, so a pin whose lease had died could
  only be given up on there (a failed read), never re-resolved, and it is the
  arm a backward read after a long pause lands on.

Reported by tschuegy in the 6.30.0 retest of #380, whose trace also answered the
open question there: the re-resolved target is the SAME edge host. What dies
across an idle is not the address but the authorization behind it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01E5UztmCZtNYPQpzdmSdmWG
…te (#392)

CI failed it where a local run passes: 0 refusals instead of 1, with the read
still reaching its target. The test paused by not reading and assumed 900 ms was
long enough for the pump to fill a 16 MB window and end at the high water. On a
loaded runner it is not, and the consequence is not a slower test but a
different one: the opening connection was still running when the lease was
armed, and a request already in flight is never re-offered to the origin's gate,
so every byte the test read came from the connection that predated the fault.

It now waits for an EVENT instead. A bounded first fetch makes the opening
connection end because its range was delivered IN FULL, so what the origin will
ever write at open is a fixed number (the range plus the speculative 64 KB
suffix), and the range cannot overrun its bound. A loaded machine delays that
number, it cannot change it. Every remaining wait is a lower bound, so slowness
only makes the pin more idle, never less, and a suffix probe that never happened
fails the test with a message rather than passing it quietly.

Verified 12/12 with the machine's cores saturated, where the old shape is the
one CI took.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01E5UztmCZtNYPQpzdmSdmWG
@superuser404notfound
superuser404notfound merged commit 3c87884 into main Aug 17, 2026
4 checks passed
@superuser404notfound
superuser404notfound deleted the fix/idle-pin-repin branch August 17, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A pinned redirect target that has carried no bytes for a minute should drop on its FIRST refusal, not ride out the keep-pin grace

1 participant