Releasing a pinned queue ring takes time proportional to the lane's backlog (#779 stage 3 pacing)

Aperta
#800 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
postgresql, rust

Direzione di ricerca

Start by reading the maintenance advance and queue prune behavior described in the issue, then inspect the existing test test_queue_ring_pin_busy_lane_is_left_to_its_claimers. Implement and measure the proposed time budget and independent pacing for reads, checking release time for 200k and 1M job lanes and claim latency while the advance runs. Done means large cleared lanes release faster without increasing prune lock pressure.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

After a pinning lane's jobs are moved or cancelled, the maintenance advance from #797 releases the queue ring at about 500 rows/s, so a large lane stays pinned long after the operator has cleared it. This body is the current state.

Observed (0.6.18 candidate, 839120ce)

A lane of 200,000 unclaimed jobs pinned the queue ring; the jobs were cancelled newest first.

  • Nothing advanced while the cancel ran, as expected: the lane's oldest job is cancelled last.
  • After the cancel finished, awa.maintenance.prune.claim_cursor_advances recorded 50 advances, about one every 8 s, each moving 4,000 positions.
  • The pin cleared 405 s after the cancel finished. The ring then advanced about one generation per second and caught up by 1,403 generations; queue prune resumed.
  • On 81b9211b (without #797) the same cancel left the ring on one generation for the whole run.

At this rate a 1M-job lane stays pinned for about half an hour after it is cleared.

Cause

Each leader read advances at most 32 lanes × 4 windows × 1,000 positions, and reads run after a queue prune that returns SkippedActive or on the refresh while prune is backed off. Prune's backoff resets only when an advanced lane leaves the oldest slot's pin, so it stays high for the whole time the advance is making progress, and the advance is paced by it.

Resetting prune's backoff after every advance would shorten this, but it makes prune retry its ACCESS EXCLUSIVE request every tick while the lane drains, which is the claim-versus-prune lock pressure behind #721. An existing test guards against that (test_queue_ring_pin_busy_lane_is_left_to_its_claimers: resetting on every read gave 22 prune attempts over 43 ticks).

Proposal (0.6.19 and main)

  1. Time-budget each read instead of a fixed window count. Keep running 1,000-position windows for a lane while each window moves a full window, up to a per-read budget (about 250–500 ms). Each window stays its own short transaction, so a claimer on that lane skips at most one poll per window and the lock footprint per transaction is unchanged.
  2. Pace the advance by its own progress, separately from prune's backoff. When a read uses its whole budget and the cursor moved, run the next read on the next maintenance tick. Stop early when a window moves nothing. Prune keeps its own backoff, which already resets when the lane leaves the pin.
  3. Measure release time for 200k and 1M-row lanes, before and after, and claim latency on the released lane while the advance runs.

Estimated, unmeasured: 10–20k positions per tick instead of 4,000 per 8 s, so a 1M-job lane releases in about a minute.

Rust only; no schema change. Related: #779, #797, #721.

Lingua principale
Rust
Stelle
37
Fork
8
Merge medio
14h 16m
PR unite (30g)
244

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di hardbyte/awa

Tutte le issue di hardbyte/awa

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.