Skip to content

Postgres: GET /api/v1/request deadlocks when two admission keys share a slot #681

Closed

Description

@n1coh

On Postgres (v3.72.31, same code in v3.72.32), opening the requests page as an admin can freeze SeerrNG. After that, Download Sync logs Scheduled job is already running every minute, scans and settings saves hang, there is no error, and only a restart helps.

Cause

  1. GET /api/v1/request takes a lease via acquireAuthorizedUserSecurityMutation (key user-security:user:1). The lease holds its admission slot until the handler ends.
  2. The handler then calls runWithCurrentServarrService('radarr', 0, …) (key service-config:radarr:0).
  3. This call runs outside the lease's AsyncLocalStorage context, so the coordinator asks for a new slot.
  4. Both keys hash to slot 5 of 8. The second call waits for the lease, and the lease waits for the handler, so neither ever finishes.

It happens when the page lists a movie request with serverId and profileId set.

Evidence

  • One session stays idle in transaction after pg_advisory_xact_lock. Its lock key matches hashtextextended('user-security:user:1', 0).
  • It came back 9 s after a restart, when a browser tab reloaded the page.
  • idle_in_transaction_session_timeout kills the session, but the app stays stuck because the wait is in the AsyncLock, not in a query.
  • Changing DB_POOL_SIZE, and therefore the slot count, cannot avoid every collision.

Possible fixes

  • Run the handler inside the lease's context, so the Radarr call reuses its transaction.
  • Or fetch the Servarr profiles outside the lease. They are only used for display.
  • Or add a timeout to slot acquisition, so the request fails with an error instead of hanging forever.

Activity

  1. snapetech commented on Nov 13, 2026

    @snapetech
    Collaborator

    Fixed on main by 1b9bb80c1. The request handler now releases its user-security admission lease after loading the request rows and before display-only Servarr profile lookups, avoiding PostgreSQL admission-slot deadlocks. The focused request-list regression test passed (1/1); the exact-main security, browser, Lumen, Semgrep, and Trivy workflows are running: Security regression tests, Lumen validation, Semgrep, Trivy.

  2. added a commit that references this issue on Nov 13, 2026
    1b9bb80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions