← ClaudeAtlas

connection-pooling-timeout-safetylisted

Connection Pooling & Timeout Safety
CarlosCaPe/octorato · ★ 5 · AI & Automation · score 72
Install: claude install-skill CarlosCaPe/octorato
# Connection Pooling & Timeout Safety > Source: [PostgreSQL Best Practices](../DOCUMENTS/PostgreSQL_BestPractices_Azure.md) > -- "Connection management and pooling", "Server configuration" ## What Configuring connection pool sizing, statement timeouts, and idle transaction timeouts to prevent resource exhaustion and runaway queries on Azure Flexible Server. ## Why PostgreSQL forks a process per connection. Without pooling and timeout guardrails: - Burst traffic can exceed `max_connections` (default 100 on small tiers) - A single unoptimized query can run for hours, holding locks - Idle transactions hold row-level locks and block autovacuum - Connection storms during deployments can crash the server These are infrastructure-level settings, but Data Engineers must understand them because: - Migration scripts can trigger long-running DDL - Bulk INSERT/UPDATE can exceed `statement_timeout` - DO blocks run as a single statement -- timeout applies to the whole block ## How ### Server Parameters (Azure Portal or CLI) ```text -- Query timeout (milliseconds). 0 = no limit. statement_timeout = 30000 -- 30 seconds for app queries -- Long migrations may need temporary increase: -- SET LOCAL statement_timeout = '5min'; -- Kill idle-in-transaction sessions (milliseconds) idle_in_transaction_session_timeout = 60000 -- 60 seconds -- Slow query logging threshold (milliseconds) log_min_duration_statement = 250 -- log queries > 250ms ``` ### Application Pool