You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test: reduce acquire_timeout_secs in test_database_pool_failure to speed up test suite 16x #281
Because setup_database defaults to acquire_timeout_secs = 30.0, sqlx waits for the entire 30 seconds before failing.
Out of the 31.94-second total pytest runtime, this single test consumes 30.00 seconds (94%), while all other 206 tests complete in 1.94 seconds!
Fix direction:
Pass an explicit short timeout in the test:
I checked this before trying the fix, and acquire_timeout_secs isn’t accepted by setup_database. In src/lib.rs the signature is #[pyo3(signature = (url, max_connections=10))], and “timeout” doesn’t appear anywhere in src. So acquire_timeout_secs=0.5 in the test would raise a TypeError.
oxyroute/_oxyroute.pyi lists min_connections, acquire_timeout_secs, idle_timeout_secs and max_lifetime_secs, but the Rust side has none of them, so the stub is ahead of the code.
To speed the test up, the parameter would have to be added in Rust first (sqlx has PgPoolOptions::acquire_timeout).
Do you want that added, or should the stub be corrected instead? I can take either one.
Hey @CodeByPeace! Great research and spot-on observation, you're 100% right.
We definitely want to implement these parameters in Rust rather than downgrading the .pyi stub! We actually just opened #290 to track full connection pool tuning for setup_database.
We'd love to have your PR for this! The plan is:
Wire min_connections, max_connections, acquire_timeout_secs, idle_timeout_secs, and max_lifetime_secs into sqlx::postgres::PgPoolOptions in src/lib.rs and forward them in oxyroute/app.py.
Use acquire_timeout_secs=0.5 in tests/test_database_pool.py:11 to speed up the test suite 16x.
Thanks, I’ll take it.
I’ll branch from dev, wire the five options into PgPoolOptions and app.py, and use acquire_timeout_secs=0.5 in the test.
I’ll also reject negative or non-finite values, since Duration::from_secs_f64 panics on them.
Opened PR #292 for this. It wires all four options into PgPoolOptions and uses acquire_timeout_secs=0.5 in the pool test, which now runs in about 0.5s instead of 30s.
Activity
CodeByPeace commentedon Oct 18, 2026
I checked this before trying the fix, and acquire_timeout_secs isn’t accepted by setup_database. In src/lib.rs the signature is #[pyo3(signature = (url, max_connections=10))], and “timeout” doesn’t appear anywhere in src. So acquire_timeout_secs=0.5 in the test would raise a TypeError.
oxyroute/_oxyroute.pyi lists min_connections, acquire_timeout_secs, idle_timeout_secs and max_lifetime_secs, but the Rust side has none of them, so the stub is ahead of the code.
To speed the test up, the parameter would have to be added in Rust first (sqlx has PgPoolOptions::acquire_timeout).
Do you want that added, or should the stub be corrected instead? I can take either one.
ZhuchkaTriplesix commentedon Oct 18, 2026
Hey @CodeByPeace! Great research and spot-on observation, you're 100% right.
We definitely want to implement these parameters in Rust rather than downgrading the
.pyistub! We actually just opened #290 to track full connection pool tuning forsetup_database.We'd love to have your PR for this! The plan is:
min_connections,max_connections,acquire_timeout_secs,idle_timeout_secs, andmax_lifetime_secsintosqlx::postgres::PgPoolOptionsinsrc/lib.rsand forward them inoxyroute/app.py.acquire_timeout_secs=0.5intests/test_database_pool.py:11to speed up the test suite 16x.Please make sure to target the integration branch
devfor your PR (seedocs/development-workflow.md).Thanks again for the thorough catch, go right ahead!
CodeByPeace commentedon Oct 18, 2026
Thanks, I’ll take it.
I’ll branch from dev, wire the five options into PgPoolOptions and app.py, and use acquire_timeout_secs=0.5 in the test.
I’ll also reject negative or non-finite values, since Duration::from_secs_f64 panics on them.
CodeByPeace commentedon Oct 18, 2026
Opened PR #292 for this. It wires all four options into PgPoolOptions and uses acquire_timeout_secs=0.5 in the pool test, which now runs in about 0.5s instead of 30s.