Skip to content

[P2] Prevent same-run PRD lease refresh from reviving released leases #7

Description

@brAperia2025

Context: CodeRabbit feedback on upstream PR coleam00#1875 surfaced a likely-valid DB race in our fork.

Problem:

  • packages/core/src/db/prd-execution-leases.ts refreshes an existing same-run lease using WHERE id = $7.
  • If another path releases the lease after the initial read, the refresh can update a released row back to active.

Impact:

  • P2 race-condition correctness issue.

Acceptance criteria:

  • Constrain the refresh UPDATE to unreleased rows, e.g. WHERE id = $7 AND released_at IS NULL.
  • Keep rowCount checks and surface a clear error when no active row remains.
  • Add a regression test for refresh after release/no-op update.

Reference:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions