Skip to content

ENG-3842: Add configurable pool_recycle for database connections#8209

Merged
erosselli merged 3 commits into
mainfrom
erosselli/ENG-3842
May 18, 2026
Merged

ENG-3842: Add configurable pool_recycle for database connections#8209
erosselli merged 3 commits into
mainfrom
erosselli/ENG-3842

Conversation

@erosselli
Copy link
Copy Markdown
Contributor

@erosselli erosselli commented May 15, 2026

Ticket ENG-3842

Description Of Changes

Adds a new FIDES__DATABASE__POOL_RECYCLE configuration setting (Optional[int], must be > 0) that controls SQLAlchemy's pool_recycle across all engine types (API sync, API async, task, async readonly). When set, connections older than this many seconds are automatically closed and replaced. This is useful when a connection proxy or firewall imposes an idle connection timeout.

When unset (None, the default), connections are never recycled — preserving current behavior with zero impact on existing deployments.

Code Changes

  • Added pool_recycle field to DatabaseSettings in database_settings.py
  • Added pool_recycle parameter to get_db_engine() in session.py, conditionally passed to create_engine
  • Wired pool_recycle through to all engine creation sites: session_management.py, tasks/__init__.py, ctl_session.py
  • Added config, session, deps, and task engine tests

Steps to Confirm

  1. Set FIDES__DATABASE__POOL_RECYCLE=1800 and verify the setting is picked up on startup
  2. Verify setting FIDES__DATABASE__POOL_RECYCLE=0 or a negative value is rejected by config validation
  3. Verify existing behavior is unchanged when the setting is not provided

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
    • Add a db-migration This indicates that a change includes a database migration label to the entry if your change includes a DB migration
    • Add a high-risk This issue suggests changes that have a high-probability of breaking existing code label to the entry if your change includes a high-risk change (i.e. potential for performance impact or unexpected regression) that should be flagged
    • Updates unreleased work already in Changelog, no new entry necessary
  • UX feedback:
    • No UX review needed
  • Followup issues:
    • No followup issues
  • Database migrations:
    • No migrations
  • Documentation:

Expose a single FIDES__DATABASE__POOL_RECYCLE setting (Optional[int], must be > 0)
that controls SQLAlchemy's pool_recycle across all engine types. When set,
connections older than this many seconds are automatically recycled. Useful
when a connection proxy or firewall imposes an idle connection timeout.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
fides-plus-nightly Ignored Ignored Preview May 18, 2026 0:32am
fides-privacy-center Ignored Ignored May 18, 2026 0:32am

Request Review

@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.61%. Comparing base (2c3849a) to head (d450f90).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8209   +/-   ##
=======================================
  Coverage   85.61%   85.61%           
=======================================
  Files         658      658           
  Lines       42869    42872    +3     
  Branches     5019     5020    +1     
=======================================
+ Hits        36701    36705    +4     
  Misses       5063     5063           
+ Partials     1105     1104    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@erosselli erosselli marked this pull request as ready for review May 18, 2026 13:48
@erosselli erosselli requested a review from a team as a code owner May 18, 2026 13:48
@erosselli erosselli requested review from vcruces and removed request for a team May 18, 2026 13:48
Copy link
Copy Markdown
Contributor

@rayharnett rayharnett left a comment

Choose a reason for hiding this comment

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

Very small change to make the pool_recycle setting configurable for SQLAlchemy. No issues identified.

@erosselli erosselli added this pull request to the merge queue May 18, 2026
Merged via the queue into main with commit 4ef9460 May 18, 2026
69 checks passed
@erosselli erosselli deleted the erosselli/ENG-3842 branch May 18, 2026 14:10
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.

2 participants