Skip to content

fix(config): global-config PUT can exhaust the DB pool when concurrent saves arm automation (permission check inside the transaction) #1517

Closed

Description

@IAmJSD

Problem

UpdateGlobalConfigAtomic runs its closure inside a transaction that holds a pool connection. When a global-config PUT arms auto-purchase, ladder execution or RI-exchange auto mode, or raises an RI-exchange cap, the closure calls requirePermission, which reads the auth store through the same pool and so needs a second connection. If as many such saves run at once on one instance as the pool has connections (Fargate's default pool is 3, Cloud Run's 6), every one of them waits forever for a connection and the instance stalls. This is the same pattern that #1509 fixed for the service-config PUT, but narrower: it needs several concurrent arming saves. It is already on main and isn't introduced by #1509.

Proposal

Resolve the caller's permissions before opening the transaction, and check them inside the closure against that snapshot, as #1509 does with the commitment options. Nothing inside the transaction should need a second pool connection or a network call.

Acceptance criteria

  • A real-Postgres regression test with a small pool and that many concurrent arming saves, which hangs before the fix and finishes quickly after it.
  • The grant checks stay exactly as strict as now.

Refs #1488, #1509

Activity

  1. IAmJSD commented on Oct 26, 2026

    @IAmJSD
    CollaboratorAuthor

    Claiming: working on this

  2. self-assigned this
    on Oct 26, 2026
  3. cristim commented on Oct 26, 2026

    @cristim
    Member

    From claude-fleet's second review of #1509 (merged as 0463051): no handler-level test covers a global-config PUT racing a service-config PUT. Worth adding alongside the fix here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions