fix(core): give sqlx pool-exhaustion errors a distinct, actionable message (PSA-40) #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/psa-40-pool-error-message"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
From<sqlx::Error> for AppError(errors/mod.rs) mapped every sqlx error, includingPoolTimedOutandPoolClosed, to the generic "A database error occurred". When a bounded pool is exhausted the log gave no hint that the cause was pool exhaustion rather than a query or connection fault. Diagnosing the bunyip BUNYIP-41 blob-cache pool starvation required reading dunite source because the surfaced message was generic.Change
Special-case the two connection-availability variants before the catch-all:
PoolTimedOut-> "database connection pool exhausted (no connection available within the acquire timeout)"PoolClosed-> "database connection pool is closed"Observability only: both remain
DatabaseError(status 500, codeDATABASE_ERROR), so existing consumers compile unchanged and no new variant is added. The catch-all is kept for genuinely unexpected variants.Acceptance criteria
Tests
sqlx::Erroris#[non_exhaustive], so its variants cannot be constructed in a test. The two regression tests provoke real values from a lazily-built pool, needing no live database or reachable host:pool_closed_maps_to_distinct_message:connect_lazythenclose()thenacquire()yieldsPoolCloseddeterministically (no network).pool_timed_out_maps_to_distinct_pool_exhaustion_message: a one-connection pool with a 150ms acquire timeout pointed at a refused loopback port (127.0.0.1:1) yieldsPoolTimedOut.fmt + clippy -D warnings clean; full
cargo test --workspacegreen (130 tests); the timed-out test verified non-flaky across 15 runs.#PSA-40