Skip to content

feat(api): make DB connection pool size configurable via env vars#2081

Merged
dobrac merged 4 commits intomainfrom
feat/configurable-db-pool-size
Mar 9, 2026
Merged

feat(api): make DB connection pool size configurable via env vars#2081
dobrac merged 4 commits intomainfrom
feat/configurable-db-pool-size

Conversation

@dobrac
Copy link
Contributor

@dobrac dobrac commented Mar 9, 2026

Summary

  • The main SQLC database pool had hardcoded max connections (40) and min idle (5) in store.go. This made it impossible to tune without a code change.
  • Adds DB_MAX_OPEN_CONNECTIONS and DB_MIN_IDLE_CONNECTIONS env vars to the API config, with defaults matching the previous hardcoded values (40 and 5).
  • Wires the new variables through the full Terraform → Nomad pipeline (variables.tfmain.tfapi.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_CONNECTIONS and DB_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.

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.
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@dobrac dobrac marked this pull request as ready for review March 9, 2026 22:21
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Copy link
Member

@jakubno jakubno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do the same for auth?

@dobrac
Copy link
Contributor Author

dobrac commented Mar 9, 2026

can we do the same for auth?

oh I though they're wired already as they exists in the env. Will add them too

dobrac added 2 commits March 9, 2026 22:40
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.
@dobrac dobrac merged commit ef09c59 into main Mar 9, 2026
36 checks passed
@dobrac dobrac deleted the feat/configurable-db-pool-size branch March 9, 2026 23:09
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.

4 participants