python.sqlalchemy.query_timeout
Stability
High
Detects SQLAlchemy queries without timeout configuration.
Why It Matters
Section titled “Why It Matters”Queries without timeout:
- Connection pool exhaustion — Slow queries hold connections
- Cascading failures — One slow query blocks others
- Resource starvation — Workers stuck waiting
Example
Section titled “Example”# ❌ Before (no timeout)result = session.execute(text("SELECT * FROM large_table"))# ✅ After (with timeout)from sqlalchemy import text
# Set statement timeout per queryresult = session.execute( text("SELECT * FROM large_table"), execution_options={"timeout": 30})
# Or set globally on engineengine = create_engine( 'postgresql://...', connect_args={"options": "-c statement_timeout=30000"})What Unfault Detects
Section titled “What Unfault Detects”- Queries without timeout configuration
- Missing statement_timeout at engine level
- Long-running queries without guards