-
-
Notifications
You must be signed in to change notification settings - Fork 313
Fix database connection exhaustion by enabling persistent connections #5319
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
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Note Free review on us!CodeRabbit is offering free reviews until Wed Dec 17 2025 to showcase some of the refinements we've made. Comment |
- Set CONN_MAX_AGE to 600 seconds (10 minutes) - Update dj_database_url.config() to use conn_max_age=600 - Add comments explaining the fix - Prevents "no more connections allowed (max_client_conn)" errors Co-authored-by: DonnieBLT <[email protected]>
Address code review feedback by adding comment explaining that db_from_env is checked later in settings.py to determine database configuration. Co-authored-by: DonnieBLT <[email protected]>
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.
Pull request overview
This PR fixes database connection exhaustion issues by enabling persistent connection pooling in Django. The application was previously opening a new database connection for every request (CONN_MAX_AGE = 0), which caused PostgreSQL to hit its maximum connection limit.
Key Changes:
- Set
CONN_MAX_AGEto 600 seconds (10 minutes) to enable connection pooling - Updated all
dj_database_url.config()calls to use consistentconn_max_age=600parameter - Added explanatory comments documenting the connection pooling configuration
Co-authored-by: Copilot <[email protected]>
|
👋 Hi @Copilot! This pull request needs a peer review before it can be merged. Please request a review from a team member who is not:
Once a valid peer review is submitted, this check will pass automatically. Thank you! |
PostgreSQL was hitting max connection limits with
OperationalError: FATAL: no more connections allowed (max_client_conn)on organization pages. The application was configured withCONN_MAX_AGE = 0, causing Django to open and close a fresh connection for every request.Changes
Updated connection pooling configuration in
blt/settings.py:CONN_MAX_AGE = 600(was0)dj_database_url.config(conn_max_age=600)in both initialization and database configuration (was0and500respectively)Connections are now reused across requests and aged out after 10 minutes of inactivity.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.