Cancelling jobs by ID on queue storage costs ~9 ms a job, mostly re-planning

Aperta
#802 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
53/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
postgresql, rust

Direzione di ricerca

Start by reading cancel_job_tx and lock_claim_heads_of_jobs_tx, then inspect the ready-row lookup and ready-reference statements described in the issue. Compare set-based cancellation with force_generic_plan using pg_stat_statements on 20k and 200k lanes. Done means lower per-job cancellation cost with measured claim-ring prune outcomes during a large cancel.

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

Descrizione

Cancelling jobs by ID on queue storage costs about 9 ms a job, so cancelling a large lane takes long transactions and holds ring partitions and claim heads for seconds per chunk. This body is the current state.

Observed

  • Soak on 839120ce: cancelling a 200,000-job lane through admin::bulk_cancel in 1,000-ID calls took 1,550 s (about 7.7 s per call). The claim ring stopped advancing for 495 s, with 65 claim-ring prunes blocked.
  • Measured with pg_stat_statements (track_planning = on) on PostgreSQL 18, release build, 250-job chunks:
    • about 9 ms a job wall time, the same at the head, middle and tail of the lane and on a 20,000-job lane, so it is not a lane-wide scan;
    • about 15 statements a job, executing in about 1.6 ms in total;
    • about 5.4 ms a job of planning: the ready-row lookup in cancel_job_tx (WITH target AS (SELECT ready.* FROM ready_entries JOIN queue_claim_heads ...)) is re-planned on almost every call at about 5.4 ms a plan, the ready-reference statement (WITH refs ... unnest) at about 1 ms, and lock_claim_heads_of_jobs_tx at about 0.85 ms. They read the partitioned ring tables, and PostgreSQL keeps choosing custom plans;
    • the rest is per-statement round trips.
  • #799's lane-visibility change does not affect it.

#801 shrinks queue-storage cancel-by-ID chunks to 250 IDs with a 100 ms pause between them, which bounds each transaction to about 2.2 s but leaves the per-job cost.

Proposal (0.6.x and main)

  1. Cancel a chunk with set-based statements: look up the chunk's ready rows, claim heads and references once per chunk instead of once per job.
  2. Or, as a smaller step, run the cancel transaction with SET LOCAL plan_cache_mode = force_generic_plan and measure the plans it gets.
  3. Measure before and after on 20k and 200k lanes, including claim-ring prune outcomes during a large cancel.

Rust only; no schema change. Related: #798, #799, #801, #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.