Skip to content

feat(db): make the [DB POOL] slow-acquire warning threshold configurable - #5397

Merged
nicoloboschi merged 3 commits into
mainfrom
fix/configurable-slow-acquire-threshold
Oct 7, 2026
Merged

nicoloboschi merged 3 commits into
mainfrom
fix/configurable-slow-acquire-threshold

Conversation

@nicoloboschi

Copy link
Copy Markdown
Collaborator

Closes #5274.

The [DB POOL] Slow acquire warning fired at a hardcoded 50 ms. On Aurora Serverless v2 a new TLS connection routinely takes 60–85 ms, so a healthy pool flooded warning dashboards.

  • New static setting HINDSIGHT_API_DB_POOL_SLOW_ACQUIRE_THRESHOLD_SECONDS (default 0.05, unchanged behaviour). 0 turns the warning off.
  • Both acquire paths (backend and legacy asyncpg) use one shared check.
  • Documented in configuration.mdx and .env.example (+ embed copy).
  • Test: a 64 ms acquire warns at the default, stays quiet at 0.1 and at 0.

Not done: adding size=/idle= to the backend-path message — the backend interface doesn't expose pool stats today.

HINDSIGHT_API_DB_POOL_SLOW_ACQUIRE_THRESHOLD_SECONDS (default 0.05, 0 disables)
replaces the hardcoded 50 ms in both acquire paths. Cold TLS connections to
Aurora Serverless routinely take 60-85 ms and flooded warning dashboards.

Closes #5274
…e legacy path

- _is_slow_acquire used get_config(), which builds a StaticConfigProxy per call
  (~0.3 ms) on every acquire; use the cached raw config instead.
- Test both acquire paths (backend and raw asyncpg pool).
@nicoloboschi
nicoloboschi force-pushed the fix/configurable-slow-acquire-threshold branch from 7b99add to de06f91 Compare October 7, 2026 13:12
@nicoloboschi
nicoloboschi merged commit 9dff2a3 into main Oct 7, 2026
117 checks passed
@nicoloboschi
nicoloboschi deleted the fix/configurable-slow-acquire-threshold branch October 7, 2026 13:49
@nicoloboschi nicoloboschi mentioned this pull request Nov 3, 2026
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.

Make the [DB POOL] slow-acquire warning threshold configurable (hardcoded 50 ms)

1 participant