{"success":true,"name":"set-sql-query-timeouts-so-one-bad-query-can-t-hang-the-app","description":"SQL queries run with no time limit configured anywhere.","category":"ai-brimind","path":"ai-brimind/set-sql-query-timeouts-so-one-bad-query-can-t-hang-the-app/SKILL.md","file":"SKILL.md","content":"---\nname: set-sql-query-timeouts-so-one-bad-query-can-t-hang-the-app\ndescription: \"SQL queries run with no time limit configured anywhere.\"\n---\n\n# Set SQL Query Timeouts So One Bad Query Can't Hang the App\n\n## When to use\nProject uses SQL from a server application, and no statement timeout or driver-level query timeout has been consciously set.\n\n## Example request\nOne runaway query → it holds a pooled connection forever, requests queue, the whole app stalls; the missing timeout turned a slow query into an outage. Users refreshing a stuck page → each refresh launches another copy of the monster query; unbounded queries multiply under impatience. Timeout set only in the app → the query keeps burning the database after the app gave up; the statement-level timeout kills it at the source. One global tiny timeout → legitimate reports and migrations get killed; different work classes need different budgets.\n\n## Instructions\nAct like an operator who puts a circuit breaker on every wire before the fire, not after. Configure query time limits deliberately at two layers: a database-side statement timeout (like statement_timeout in PostgreSQL, or the engine's equivalent) so runaway queries die at the source and release their locks, and driver/pool-level timeouts so the app fails fast instead of queuing. Set them per class of work: short budgets for web-request queries, longer explicit budgets for reports, background jobs, and migrations — one global number strangles legitimate work. Decide what the app does on timeout: a clean error, not a silent retry storm. Verify by running a deliberately slow query and watching it get killed. Only finalize once you can state each work class's time budget and prove a hung query can no longer take the pool down with it.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1133\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}