Fix #34: Database connection pool not configured with connection limits or error handling - #37
Merged
Merged
Conversation
…ts or error handling
Owner
|
@nandanadileep Thank you for your contributing. |
Owner
|
@nandanadileep plz update Description before merging this PR. |
Contributor
Author
|
@RenzoMXD Updated the PR description with the details. |
Owner
|
@nandanadileep please fix ci test failing. |
Owner
|
Thanks for your contribution. @nandanadileep |
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
Fixes #34 by configuring the PostgreSQL connection pool with production-ready limits, timeouts, and error handling, and by adding graceful shutdown logic.
Problem
backend/src/database/client.tscreated aPoolwith onlyconnectionString. Under load this can lead to:Changes
backend/src/database/client.tsDB_POOL_MAX(default20)DB_POOL_MIN(default2)DB_IDLE_TIMEOUT(default30000ms)DB_CONNECTION_TIMEOUT(default5000ms)allowExitOnIdle: falseto keep the process alive while the pool is runningpool.on('error', …)handler so idle-client errors are logged instead of crashing the processclosePool()helper for clean shutdownbackend/src/server.tspoolserverinstance returned byapp.listenSIGTERMhandler that:Environment variables
No breaking changes. Existing deployments keep working because every new setting has a sensible default. Optional overrides:
DB_POOL_MAX20DB_POOL_MIN2DB_IDLE_TIMEOUT30000DB_CONNECTION_TIMEOUT5000Testing
DATABASE_URLsetSIGTERMcloses the pool and exits without open handlesRelated