Queue storage: cancel_by_unique_key without a queue still reads every retained receipt claim

Abierto
#587 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
47/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
postgresql, rust

Línea de trabajo

Start by reading the unscoped cancel_by_unique_key and cancel_by_unique_key_tx paths, open_receipt_running_claims_sql, and the existing test_queue_storage_cancel_by_unique_key_reads_live_work_only test. Compare the three proposed approaches against the oldest-nonterminal semantics and the 0.7 partition migration cost. Done means the extended test shows rows read stay flat as other queues' backlogs and retained claims grow, without changing which job is selected.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Follow-up to #585 / #586.

With a queue, admin::cancel_by_unique_key / cancel_by_unique_key_tx now start from that queue's ready rows holding the key. They check only those jobs for being available, leased or on an open receipt claim, and answer from the deferred_jobs key index when the queue has no such row. That cost follows the queue's own rows.

Without a queue (keys inserted without by_queue), the lookup still:

  • walks every lane's available rows from its claim cursor;
  • reads every open receipt claim (open_receipt_running_claims_sql) before filtering by key.

The second part grows with claim-ring retention. A long-running job keeps the oldest claim slot from pruning, so row-local claims from completed jobs pile up behind it.

Measurement

Default awa schema on PostgreSQL 16, with 180,200 retained ready rows and 120,300 retained row-local claims in other queues. The lookup was timed through cancel_by_unique_key_tx, rolled back:

p50
0.6.9 lookup (any key) 2.8 s
Pre-fix 0.6.10 lookup with a queue (reads the claim ring like the unscoped path) 9.7 s
Key-first lookup with a queue: missing key 1.7 ms
Key-first lookup with a queue: cancel a scheduled job 11 ms
Key-first lookup with a queue: cancel an available job 20 ms

Unscoped lookups still behave like the pre-fix row.

Options
  1. awa.job_unique_claims as a fast path. Look up job_id by unique_key, then confirm it with a per-job state check.
    • As #585 notes, it can't replace the lookup. A claim exists only while its job's state is inside its unique_states mask, and the API promises the oldest nonterminal job holding the key.
    • So a hit can return a job when no live job outside the mask can share the key; a miss still needs the fallback.
    • It helps the common default mask, but not a missing key.
  2. A partial index on ready_entries (unique_key) WHERE unique_key IS NOT NULL. With it, an unscoped lookup can start from the key the way a scoped one starts from the queue.
    • It costs every unique enqueue and needs an upgrade path for existing partitions (0.7 migration).
  3. Leave unscoped lookups as they are and document the cost. Point callers at by_queue keys or cancel-by-id for latency-sensitive paths.
Done when

An unscoped lookup's rows read stay flat as other queues' backlogs and retained claims grow (extend test_queue_storage_cancel_by_unique_key_reads_live_work_only), and the oldest-nonterminal semantics are unchanged.

Lenguaje dominante
Rust
Estrellas
37
Forks
8
Merge medio
14 h 16 min
PR fusionados (30 d)
244

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de hardbyte/awa

Todos los issues de hardbyte/awa

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.