RSpec Connection Pool Exhaustion – Diagnose cleanup strategy
0 reputation · 17 Jan 2026, 10:56 UTC
Diagnosing Intermittent Connection Pool Exhaustion
The goal is to determine whether the observed pool exhaustion during long‑running RSpec suites is caused by the default transactional fixture handling or by the DatabaseCleaner strategy employed. Constraints include the Rails version (≥6 with connection reaping), the presence of background‑job‑like tests that open extra connections, and the configuration of config.after(:suite) for cleanup.
Key uncertainties revolve around whether config.use_transactional_fixtures = true guarantees immediate return of connections to the pool after each test, and how DatabaseCleaner.clean_with(:truncation) interacts with the pool’s state. The interaction of config.after(:suite) cleanup with Rails’ connection reaping also remains unclear.
To resolve these, consider the following questions:
- Does
use_transactional_fixturesalways return connections to the pool immediately after each test? - What effect does
DatabaseCleaner.clean_with(:truncation)have on the pool’s available connections duringafter(:suite)? - In a CI environment, how does the timing of connection reaping influence intermittent exhaustion reports?