Supported API to change a queue's enqueue_shards, picked up by running producers

Aperta
#670 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
postgresql, python, rust
Ambito
backend, cli, databases

Direzione di ricerca

Start with QueueStorage::prepare_queue, QueueStorage::enqueue_shards_cache, and shard_for_enqueue, then read the sharding section in docs/configuration.md and the linked operations skill. Trace how queue striping maps a logical queue to physical queues and how lane provisioning interacts with queue_meta. Done means the API and CLI behavior, producer refresh behavior or documented limitation, tests for PostgreSQL 17 and 18, documentation, changelog, and 0.6 backport meet the listed criteria.

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

Descrizione

Changing a queue's enqueue_shards today means hand-writing SQL against awa.queue_meta, and the change does not reach running producers until they restart. Operators fill the gap with ad-hoc SQL against lane internals (head tables, ensure_lane_sequences, lane advisory-lock keys), which is brittle across releases.

Gaps

  1. No supported operation sets the shard count. The documented path is an INSERT … ON CONFLICT upsert into awa.queue_meta (configuration). QueueStorage::prepare_queue / awa storage prepare-queue provisions lanes but does not change queue_meta, so provisioning and switching are two steps an operator has to order correctly. The upsert also needs the physical queue names when queue striping is in use, which prepare_queue already handles for its own step.
  2. Running producers keep the shard count they first read. QueueStorage::enqueue_shards_cache is filled lazily by shard_for_enqueue and cleared only by reset(). After a change, Rust producers keep enqueueing with the old count until the process restarts, while enqueues through the SQL insert functions read queue_meta per statement and switch at commit. Raising and lowering both behave this way. The docs say lowering "is safe at any time" but don't mention the restart.
  3. On 0.6.x before the definer_lane_provisioning patch, raising the count without provisioning first is unsafe with more than one runtime role. The first producer or maintenance leader to touch a new shard creates its lane sequences as its own role, without grants for the other runtime roles. v053 on 0.7 and the 0.6.14 patch fix this; the API below should not rely on callers knowing it.

Proposal

  • A Rust API, e.g. QueueStorage::set_enqueue_shards(pool, queue, shards), taking the logical queue name. In one transaction it validates 1..=64, provisions every priority × shard lane for each physical queue when raising, and upserts queue_meta for each physical queue. No producer can then see the new count before its lanes exist. Lowering needs no provisioning.
  • A CLI command for the same operation, e.g. awa storage set-enqueue-shards --queue <q> --shards <n> (or --set on prepare-queue), and a Python binding if prepare_queue is exposed there.
  • Running producers pick up the new count within a bounded interval without a restart. That means a refresh with a TTL, or reusing an existing periodic refresh, as long as it adds no per-enqueue query. If that isn't practical, document the restart requirement for both raising and lowering.

Done when

  • Tests on PostgreSQL 17 and 18 cover:
    • an atomic raise, where no enqueue lands on an unprovisioned shard;
    • idempotent re-runs;
    • lowering;
    • a running producer switching shard count without a restart (or the documented limitation);
    • striped queues.
  • docs/configuration.md, the CHANGELOG and the awa-operations skill describe the API in place of the raw upsert.
  • Backported to the 0.6 line.
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.