Queue-ring pruning leaves unique claims owned by jobs it has removed

オープン
#577 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
postgresql, rust
領域
backend, databases

調査の方向性

Start with awa-model/src/queue_storage.rs, especially sync_unique_claim, prune_oldest, and the truncate helper; read awa-model/src/job.rs for the default UniqueOpts behavior. Then trace enqueue handling in awa-worker/src/enqueue_specs.rs and build the real PostgreSQL lifecycle verification described in the issue. Done means pruning releases only claims owned by jobs with no remaining qualifying evidence, while preserving surviving or carried owners and passing the listed concurrency, rollback, and follow-up cases.

索引モデルが issue の本文から書いたものです。

説明

Assistant-generated review (Codex). Source checked on main f644f321ad110c6436382b64bdc0d935dcdeba5a and PR572 head 512f477785d327ac092b94c6a399db4a8b5c4555. This predates PR572. Native PostgreSQL reproduction was not run in this session.

Default UniqueOpts includes completed jobs (job.rs:217–237). That makes a retained completed job suppress a duplicate. But ownership survives after retention removes its final job evidence:

  • sync_unique_claim deletes only when a transition leaves the configured unique-state mask. Available → running → completed stays inside the default mask.
  • prune_oldest carries retained failures, folds counts and truncates the ready/terminal children. Its truncate helper does not release uniqueness ownership.
  • awa.job_unique_claims has unique_key and job_id, with no FK/expiry that removes the orphan.

Source-derived minimal case:

  1. Enqueue a job with UniqueOpts::default(); complete it.
  2. Rotate/prune until its last retained job evidence is removed.
  3. Check that the old job is absent but its row remains in awa.job_unique_claims.
  4. Enqueue the same unique key again: the surviving owner can still reject it.

This matters beyond an insert error. COPY can skip a duplicate, and follow-up insertion treats the unique conflict as a duplicate under a savepoint. A later parent can therefore complete while a newly intended follow-up is suppressed by an owner whose job no longer exists.

Expected invariant: if uniqueness is scoped to retained qualifying jobs, removing a job's final qualifying evidence also releases only that job's ownership, atomically. Permanent idempotency would need a separate explicit lifetime policy. PR571's “Separate finding” already reports a local reproduction of this leak; this issue gives that finding a focused tracker rather than attributing it to PR572.

The fix must not release a claim merely because an old ready version appears in the pruned slot: the same job may have surviving live/deferred/DLQ evidence or a carried failed row elsewhere. Guard deletion by key and owner job ID, preserve carried/surviving owners, and review prune/enqueue/completion lock ordering. A sweep based only on an empty advisory lookup is unsafe.

Needed verification on PG17 and PG18: real enqueue → complete → prune → enqueue; unique staged/registered follow-ups; failed carry; retries that leave old ready versions; custom substrates; concurrent duplicate enqueue; prune rollback. Also define a guarded audit/repair procedure for existing orphan owners.

Evidence limit: source tracing plus an offline lifecycle model here, not a native final-head test or a claim that Brian ran one. Related testing umbrella: #562.

主要言語
Rust
スター
37
フォーク
8
平均マージ
14時間 16分
マージ済み PR(30日)
244

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

hardbyte/awa のほかの issue

hardbyte/awa の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。