Skip to content

feat: add environment variables to allow configuration of django persistent connections#1861

Merged
gustavobtflores merged 1 commit intokernelci:mainfrom
gustavobtflores:feat/django-persistent-connections
Apr 16, 2026
Merged

feat: add environment variables to allow configuration of django persistent connections#1861
gustavobtflores merged 1 commit intokernelci:mainfrom
gustavobtflores:feat/django-persistent-connections

Conversation

@gustavobtflores
Copy link
Copy Markdown
Contributor

@gustavobtflores gustavobtflores commented Apr 16, 2026

Description

Add configurable Django persistent database connections to reduce connection overhead in production environments. This allows database connections to be reused across requests instead of opening and closing a connection for each request.

Changes

  • Add DB_CONN_MAX_AGE environment variable to configure connection persistence (defaults to 0 for development safety)
  • Add DB_CONN_HEALTH_CHECKS environment variable to verify connections before reuse (defaults to False)

Closes #1862

@gustavobtflores gustavobtflores self-assigned this Apr 16, 2026
@gustavobtflores gustavobtflores added enhancement New feature or request Database Issue that alters only configs of a database itself labels Apr 16, 2026
@tales-aparecida
Copy link
Copy Markdown

Consider how cronjobs interact with this. I recall hearing a history of a bug in CKI about it, but I don't know exactly what happened and why, so just think about it

@gustavobtflores
Copy link
Copy Markdown
Contributor Author

gustavobtflores commented Apr 16, 2026

Consider how cronjobs interact with this. I recall hearing a history of a bug in CKI about it, but I don't know exactly what happened and why, so just think about it

If a cronjob runs frequently enough to keep the connection open, that could be a problem. However, as far as I know, we don't have any running that frequently, so it shouldn't be an issue.

Copy link
Copy Markdown
Collaborator

@MarceloRobert MarceloRobert left a comment

Choose a reason for hiding this comment

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

LGTM, looked at the docs and seems to be good

@gustavobtflores gustavobtflores added this pull request to the merge queue Apr 16, 2026
Merged via the queue into kernelci:main with commit 9053990 Apr 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Database Issue that alters only configs of a database itself enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable Django persistent database connections for production

3 participants