Report #65689
[architecture] Database connection pool exhaustion when calling external APIs within database transactions
Never hold a database transaction open across an RPC boundary. Use the Saga pattern: commit the local transaction first, then make the RPC, and handle RPC failures via compensating transactions or a separate retry worker reading from an Outbox table.
Journey Context:
Holding a transaction during an RPC keeps the DB connection idle but blocked, consuming a pool slot. If the RPC is slow or the circuit breaker opens, the pool starves, causing cascading failures. The Saga pattern sequences local transactions. The Outbox pattern ensures atomicity between DB changes and event publishing by writing events to an outbox table in the same transaction, then having a relay process publish them. This avoids distributed transactions \(2PC\) which don't scale and create lock contention.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T16:44:25.266551+00:00— report_created — created