Skip to content

Let a long poll's later probe wait for a read slot until its deadline - #1380

Merged
rmcdaniel merged 2 commits into
mainfrom
general/server-1372-later-probe-wait
Nov 26, 2026
Merged

rmcdaniel merged 2 commits into
mainfrom
general/server-1372-later-probe-wait

Conversation

@rmcdaniel

@rmcdaniel rmcdaniel commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Part of #1372.

Split out of #1378 at review. The fix doesn't depend on the pool size, and it matters more with one read slot.

Problem

A held poll's later probe (any probe after its first) waits for a read slot. The wait ended at the earlier of two deadlines: the poll's own deadline, or the pool's 5 s acquisition deadline.

  • With many held polls queued on the read slot, a long poll that still had time left could run out of the 5 s acquisition deadline first.
  • It then failed with the typed pool timeout: HTTP 503 storage_unavailable, pool_timeout.

Change

budgeted_connection_by (probe_connections.rs) changes as follows.

  • Later probes: the slot wait now lasts until the poll's own deadline, however long that is. If no slot is free by then, the poll answers as at its deadline, as Keep registrations and producers answering through database stalls #1358 made it do.
  • After the slot: once the slot is held, the connection gets the 5 s acquisition deadline from that moment.
  • Unchanged: the first probe's fence and readiness reads, admission and every claim keep the single 5 s deadline for the slot and connection together. The first pass's cross-kind wake read (for workers that opted in) also gets the longer wait.
  • Known effects (review): the storage-pressure admission check (Native: storage admission (disk-pressure drain and fence) for 3.1 #951) runs before the slot wait, so a claim can now act on a check up to the poll's timeout old instead of about 5 s. Under extreme load, later probes no longer drop out after 5 s, so admissions and first probes, which keep the 5 s cap, are the ones that get 503. Both are noted on Serve high held-poll counts without a single node-wide probe read slot #1372.
  • Docs: docs/server-reference.md (native long-poll capacity).

Test

sqlite_a_long_poll_keeps_waiting_for_a_read_slot_past_the_acquisition_deadline uses a SQLite store whose pool has a 2 s acquisition deadline, and a poll with a 6 s timeout.

  1. The read slot is held right after the poll's first probe, for the acquisition deadline plus 1.5 s.
  2. A workflow is then started and the slot freed.
  3. The poll must lease that workflow.
  4. It must still have been waiting when the slot freed (it answered after that moment), and it must answer within 1 s of it.

This replaces the earlier assertion started.elapsed() >= freed, which the review pointed out was always true.

  • Before (main's slot wait restored in a scratch build): FAILED, a slot wait past the acquisition deadline is not a pool timeout: Database(PoolTimedOut).
  • After: ok.

The other probe-connection and transition-queue tests also pass (8 passed, 2 ignored, which need a database).

🤖 Generated with Claude Code

A held poll's later probe waited for a read slot with the pool's
five-second acquisition deadline whenever its own deadline was further
away: with one read slot and many held polls, a slot wait that outlasted
five seconds while the poll still had time failed the poll with the typed
pool timeout (HTTP 503). A later probe now waits for the slot until the
poll's own deadline, however long, and answers as at its deadline if none
is free by then (Server #1355). The connection, once the slot is held,
keeps the acquisition deadline; the first probe, admission and every claim
keep it for the slot too.

sqlite_a_long_poll_keeps_waiting_for_a_read_slot_past_the_acquisition_deadline
holds the read slot after a poll's first probe for longer than its test
pool's two-second acquisition deadline, then starts a workflow and frees
the slot: the poll must still be waiting when the slot frees and lease the
workflow within a second. With the old slot wait it fails with
Database(PoolTimedOut).

Part of #1372.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rmcdaniel

Copy link
Copy Markdown
Member Author

Independent review (fresh reviewer agent, given this PR and #1372): PASS at 618b89583280bee65e596ff6cca9c1151de36478.

  • No claimable task is dropped: a timed-out wait takes the existing empty/no-task answer path.
  • Receipts and replay are unchanged, and acquiring a connection stays capped at 5 s once the slot is held.
  • No deadlock or starvation.
  • The test is deterministic and fails before / passes after.

Non-blocking findings, now noted in the description and on #1372:

  • the first pass's cross-kind read also gets the longer wait;
  • the storage-pressure snapshot can be older before a claim;
  • load shifts to admissions and first probes under extreme load;
  • one assertion is vacuous.

The branch was then updated with main by a merge commit only, with no code change to this PR.

@sonarqubecloud

Copy link
Copy Markdown

@rmcdaniel
rmcdaniel added this pull request to the merge queue Nov 26, 2026
Merged via the queue into main with commit d7b4a8b Nov 26, 2026
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant