Skip to content

Add statement timeout support#120

Draft
EDsCODE wants to merge 1 commit intomainfrom
feature/statement-timeout
Draft

Add statement timeout support#120
EDsCODE wants to merge 1 commit intomainfrom
feature/statement-timeout

Conversation

@EDsCODE
Copy link
Contributor

@EDsCODE EDsCODE commented Jan 30, 2026

Summary

  • Adds configurable query timeout to prevent runaway queries
  • Queries exceeding timeout are cancelled with SQLSTATE 57014

Changes

  • Add QueryTimeout to Config struct (default: 0 = disabled)
  • Add query_timeout YAML config and DUCKGRES_QUERY_TIMEOUT env var
  • Create queryContext() helper that wraps queries with timeout
  • Update all db.Query/db.Exec calls to use context
  • Add duckgres_query_timeouts_total Prometheus metric

Configuration

query_timeout: "30s"  # or via DUCKGRES_QUERY_TIMEOUT=30s

Test plan

  • Set short timeout, run slow query - should timeout with error
  • Verify metric increments on timeout
  • Verify queries complete normally when under timeout

🤖 Generated with Claude Code

Adds query_timeout configuration option that cancels queries exceeding
the specified duration. Prevents runaway queries from blocking
connections indefinitely.

Changes:
- Add QueryTimeout to server.Config struct
- Add query_timeout to YAML config and DUCKGRES_QUERY_TIMEOUT env var
- Add queryContext() helper returning context with timeout
- Update all db.Query/db.Exec calls to use context variants
- Return SQLSTATE 57014 (query_canceled) on timeout
- Add duckgres_query_timeouts_total Prometheus metric
- Add PLAN.md to .gitignore for local planning docs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@EDsCODE EDsCODE force-pushed the feature/statement-timeout branch from a05ce98 to e0928cc Compare January 30, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant