feat(api): make DB connection pool size configurable via env vars#2081
feat(api): make DB connection pool size configurable via env vars#2081
Conversation
The main SQLC database pool had hardcoded max connections (40) and min idle (5). This adds DB_MAX_OPEN_CONNECTIONS and DB_MIN_IDLE_CONNECTIONS env vars, propagated through the Terraform -> Nomad pipeline, so pool sizes can be tuned per environment without code changes.
There was a problem hiding this comment.
Incomplete Terraform wiring — per-environment override not actually possible
The PR's stated goal is to allow pool sizes to be tuned per environment, but iac/provider-gcp/nomad/main.tf (module "api" block) never passes db_max_open_connections or db_min_idle_connections to the job-api module, and iac/provider-gcp/nomad/variables.tf doesn't declare them either. As a result the values always resolve to the module-level defaults (40 and 5) and cannot be overridden at the environment level without additional changes. These variables need to be declared in iac/provider-gcp/nomad/variables.tf and forwarded in the module "api" call.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f94c16d4f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 409f98ff62
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
oh I though they're wired already as they exists in the env. Will add them too |
Add AUTH_DB_MAX_OPEN_CONNECTIONS and AUTH_DB_MIN_IDLE_CONNECTIONS to the full Terraform -> Nomad chain (Makefile, provider-gcp variables, nomad variables, job-api module, HCL template) so auth DB pool sizes can be tuned per environment.
Add DB_MAX_OPEN_CONNECTIONS, DB_MIN_IDLE_CONNECTIONS, AUTH_DB_MAX_OPEN_CONNECTIONS, and AUTH_DB_MIN_IDLE_CONNECTIONS to the AWS provider Terraform chain, matching the GCP setup.
Summary
store.go. This made it impossible to tune without a code change.DB_MAX_OPEN_CONNECTIONSandDB_MIN_IDLE_CONNECTIONSenv vars to the API config, with defaults matching the previous hardcoded values (40 and 5).variables.tf→main.tf→api.hcl), so pool sizes can be overridden per environment.Note
Low Risk
Low risk: this only parameterizes existing DB pool sizing and keeps the previous defaults, with the main impact limited to deployment-time configuration mistakes (e.g., setting values too high/low).
Overview
Makes the API’s primary Postgres connection pool sizing configurable by introducing
DB_MAX_OPEN_CONNECTIONSandDB_MIN_IDLE_CONNECTIONS(defaulting to the prior hardcoded values) and wiring them end-to-end through Terraform/Nomad into the runtime config so environments can tune DB connection usage without code changes.Written by Cursor Bugbot for commit 1981678. This will update automatically on new commits. Configure here.