Skip to content

Conversation

@erosselli
Copy link
Contributor

Ticket []

Description Of Changes

Adds setting to disable connection pooling and use NullPool instead.

Code Changes

Steps to Confirm

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:
    • All UX related changes have been reviewed by a designer
    • No UX review needed
  • Followup issues:
    • Followup issues created
    • No followup issues
  • Database migrations:
    • Ensure that your downrev is up to date with the latest revision on main
    • Ensure that your downgrade() migration is correct and works
      • If a downgrade migration is not possible for this change, please call this out in the PR description!
    • No migrations
  • Documentation:
    • Documentation complete, PR opened in fidesdocs
    • Documentation issue created in fidesdocs
    • If there are any new client scopes created as part of the pull request, remember to update public-facing documentation that references our scope registry
    • No documentation updates required

@erosselli erosselli requested a review from a team as a code owner January 9, 2026 22:19
@erosselli erosselli requested review from galvana and removed request for a team January 9, 2026 22:19
@vercel
Copy link
Contributor

vercel bot commented Jan 9, 2026

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

2 Skipped Deployments
Project Deployment Review Updated (UTC)
fides-plus-nightly Ignored Ignored Jan 9, 2026 10:19pm
fides-privacy-center Ignored Ignored Jan 9, 2026 10:19pm

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Summary

This PR adds a new configuration setting api_engine_disable_pooling to allow disabling database connection pooling for API engines (both sync and async). This is a straightforward feature addition that enables use cases like serverless deployments or development environments where connection pooling may not be desirable.

Changes Overview

  1. database_settings.py: Added new boolean field api_engine_disable_pooling (default: False) with appropriate documentation
  2. deps.py: Updated get_api_session() and get_readonly_api_session() to pass the disable_pooling parameter to get_db_engine()
  3. ctl_session.py: Refactored async engine creation to conditionally apply pooling based on the new setting, using SQLAlchemy's NullPool when disabled

Implementation Quality

  • Correctness: The logic properly implements the feature with mutually exclusive code paths for pooling vs. non-pooling configurations
  • Consistency: The setting is correctly applied to all API engines (sync, async, readonly sync, readonly async)
  • Backward Compatibility: When the setting is not configured (defaults to False), behavior is identical to the previous version
  • No Functional Bugs: The implementation correctly handles edge cases and follows existing patterns in the codebase

Issues Found

The primary issue is a missing changelog entry. Per the project's changelog fragment system, a file should be created at changelog/7208.yaml documenting this new feature.

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk pending the addition of a changelog entry.
  • Score reflects a clean implementation of a straightforward feature with proper integration across all API engines and backward compatibility. The single issue is a documentation/administrative one (missing changelog entry) rather than a functional bug. The code logic is sound with no edge cases or error handling concerns identified.
  • Only the missing changelog entry needs attention - no code files require modifications.

Important Files Changed

File Analysis

Filename Score Overview
src/fides/config/database_settings.py 5/5 Added new configuration setting api_engine_disable_pooling (bool, default=False) to allow disabling connection pooling for API engines. Change is minimal and straightforward - just adds a new Field to the DatabaseSettings class. No issues detected.
src/fides/api/db/ctl_session.py 4/5 Refactored async engine creation to conditionally apply pooling settings based on api_engine_disable_pooling. The logic correctly uses NullPool when disabled, and applies pool_size/max_overflow/pool_pre_ping when enabled. The same settings are applied to both primary and readonly async engines. Refactoring is correct and maintains existing behavior. Note: sync_engine (line 79) still doesn't respect disable_pooling setting, but this appears to be pre-existing behavior per the TODO comment on line 76-78.
src/fides/api/api/deps.py 4/5 Added disable_pooling=CONFIG.database.api_engine_disable_pooling parameter to both get_api_session() and get_readonly_api_session() when calling get_db_engine(). The parameter is correctly passed and properly applied. Both API and readonly sessions now respect the pooling setting. Implementation is correct and consistent.

Comment on lines +57 to +60
api_engine_disable_pooling: bool = Field(
default=False,
description="If true, the engine will not use a connection pool.",
)
Copy link
Contributor

Choose a reason for hiding this comment

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

This PR adds a new configuration setting but is missing a changelog entry. Please create a new file in the changelog/ directory following the pattern described in changelog/README.md. For this PR, create changelog/7208.yaml with the following structure:

type: Added
description: Added configuration setting to disable database connection pooling for API engines
pr: 7208

If this change is high-risk or includes database migrations, also add the corresponding labels to the labels field.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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.

3 participants