fix: configure SQLAlchemy connection pool with env-driven settings#174
Open
snowrugar-beep wants to merge 1 commit into
Open
fix: configure SQLAlchemy connection pool with env-driven settings#174snowrugar-beep wants to merge 1 commit into
snowrugar-beep wants to merge 1 commit into
Conversation
…B_MAX_OVERFLOW, DB_POOL_RECYCLE) with shared helper (Quantarq#59)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Configures SQLAlchemy engine pool settings (
pool_size,max_overflow,pool_recycle, withpool_pre_pingalways enabled) on both engine construction sites in the project. Eliminates the silent defaults that previously allowed connection exhaustion and stale-connection failures under load.Changes
_engine_pool_kwargs()inweb_app/db/database.py(single source of truth).init_engine(db_url)factory; bothinit_dbandDBConnector.__init__now route throughweb_app.db.database.create_enginewith the shared pool policy.tests/test_db_pool.pyverifying both engine sites forward the env-driven kwargs and fall back to defaults.import os/import create_enginefromweb_app/db/crud/base.py.DB_POOL_SIZE=5,DB_MAX_OVERFLOW=10,DB_POOL_RECYCLE=1800. All overridable via env.Testing
python -m py_compileclean acrossdatabase.py,crud/base.py, and the new test file.pytest web_app/tests/test_db_pool.pyvalidates kwarg forwarding under both set-env and unset-env scenarios.Closes #59