feat(db): configurable Postgres statement_timeout on pool connections#1200
Merged
Conversation
…ctions Adds HINDSIGHT_API_DB_STATEMENT_TIMEOUT (default 600s, set 0 to disable). Applied via the asyncpg pool init hook, so it only affects runtime queries — Alembic migrations run on a separate psycopg2 engine and are untouched. Also fixes the ANN chunk path in the retain orchestrator to restore the pool's configured statement_timeout rather than RESET, which would fall back to the server default and silently drop the safety net on that pooled connection.
…_ann Now that the asyncpg pool applies a Postgres statement_timeout to every connection (HINDSIGHT_API_DB_STATEMENT_TIMEOUT, default 600s), the ANN path can be treated like any other query — no need for the 300s asyncpg per-query timeout or the orchestrator's SET/restore dance around the pool's default.
…hange Re-runs scripts/generate-docs-skill.sh so the skill reference mirror matches the HINDSIGHT_API_DB_STATEMENT_TIMEOUT row added in hindsight-docs/docs/developer/configuration.md. Also picks up unrelated drift (openapi.json version bump, changelog index) that had accumulated on main.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HINDSIGHT_API_DB_STATEMENT_TIMEOUT(default 600s,0disables), applied via the asyncpg poolinithook so every runtime connection gets a server-side safety net for runaway queries.hindsight_api/migrations.py+alembic/env.py), which bypasses the asyncpg pool.retain/orchestrator.pyto restore the pool's configuredstatement_timeoutin afinallyblock instead ofRESET.RESETfalls back to the Postgres server default, which would silently drop the safety net on that pooled connection after the ANN tightening to 300s.Test plan
./scripts/hooks/lint.shpassesHindsightConfig.from_env()readsdb_statement_timeout=600by default and honorsHINDSIGHT_API_DB_STATEMENT_TIMEOUT=0to disableSHOW statement_timeout;on a pool connection returns10minHINDSIGHT_API_DB_STATEMENT_TIMEOUT=0, verify pool connections report0(unlimited)CREATE INDEX CONCURRENTLYunaffected)