Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tcf_core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@
"PASSWORD": env.str("AWS_RDS_PASSWORD"),
"HOST": env.str("AWS_RDS_HOST"),
"PORT": env.int("AWS_RDS_PORT"),
# Connection pooling - reuse connections between requests
"CONN_MAX_AGE": 60, # Keep connections alive for 60 seconds
# Health checks (Django 4.1+) - verify connection is still valid
"CONN_HEALTH_CHECKS": True,
# Database connection options
"OPTIONS": {
"connect_timeout": 10, # Timeout for establishing connection
"options": "-c statement_timeout=30000", # 30 second query timeout
},
Comment on lines +107 to +115
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Apply connection settings to dev environment for consistency.

These database connection settings are only applied to the AWS RDS (production) configuration but not to the dev configuration (lines 59-68). This creates an environment inconsistency that could mask production issues during development.

Apply this diff to add similar settings to the dev database configuration:

    DATABASES = {
        "default": {
            "NAME": env.str("DB_NAME"),
            "ENGINE": "django.db.backends.postgresql_psycopg2",
            "USER": env.str("DB_USER"),
            "PASSWORD": env.str("DB_PASSWORD"),
            "HOST": env.str("DB_HOST"),
            "PORT": env.int("DB_PORT"),
+           "CONN_MAX_AGE": 60,
+           "CONN_HEALTH_CHECKS": True,
+           "OPTIONS": {
+               "connect_timeout": 10,
+               "options": "-c statement_timeout=30000",
+           },
        }
    }

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In tcf_core/settings/base.py around lines 107-115 and the dev DB block at lines
~59-68, the connection pooling and options (CONN_MAX_AGE, CONN_HEALTH_CHECKS,
and OPTIONS with connect_timeout and options="-c statement_timeout=30000") are
only applied to production; add the same keys to the dev DATABASES['default']
configuration so dev uses identical connection settings. Update the dev DB dict
to include "CONN_MAX_AGE": 60, "CONN_HEALTH_CHECKS": True, and an "OPTIONS" dict
containing "connect_timeout": 10 and "options": "-c statement_timeout=30000" (or
merge these using an existing shared settings dict if present) and keep/update
comments to reflect the intent.

}
}

Expand Down