-
Notifications
You must be signed in to change notification settings - Fork 84
Add setting to disable connection pooling #7208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
There was a problem hiding this 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
- database_settings.py: Added new boolean field
api_engine_disable_pooling(default: False) with appropriate documentation - deps.py: Updated
get_api_session()andget_readonly_api_session()to pass thedisable_poolingparameter toget_db_engine() - ctl_session.py: Refactored async engine creation to conditionally apply pooling based on the new setting, using SQLAlchemy's
NullPoolwhen 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. |
| api_engine_disable_pooling: bool = Field( | ||
| default=False, | ||
| description="If true, the engine will not use a connection pool.", | ||
| ) |
There was a problem hiding this comment.
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: 7208If 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!
Ticket []
Description Of Changes
Adds setting to disable connection pooling and use NullPool instead.
Code Changes
Steps to Confirm
Pre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and works