837 backend pg pool created without max idle connection statement timeout settings - #1175
Merged
Conversation
… remove unused eslint directive in logger (LabsCrypt#847)
…pr-test-gate workflow (LabsCrypt#847)
…timeouts (LabsCrypt#837) - Support env configuration for PG_POOL_MAX, PG_IDLE_TIMEOUT_MS, PG_CONNECTION_TIMEOUT_MS, PG_STATEMENT_TIMEOUT_MS in createPgPoolConfig with sane defaults - Document pool settings in backend/.env.example - Accept optional config overrides in createPgPool - Expand unit tests for default, custom env, invalid inputs, and overrides
4 tasks
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.
Description
This PR addresses issue #837 by ensuring
pg.Poolis constructed with environment-configurable settings for maximum pool size, connection timeouts, idle timeouts, and statement execution timeouts. Previously,pg.Poolwas instantiated with no explicit tuning, usingnode-postgresdefaults (max 10 connections, no statement timeout), which risked connection pool exhaustion and unbound slow query execution under load.Type of Change
Related Issues
Closes #837
Changes Made
backend/src/lib/pg-pool.ts:createPgPoolConfigwith sane default fallbacks:PG_POOL_MAX:10PG_IDLE_TIMEOUT_MS:30000(30s)PG_CONNECTION_TIMEOUT_MS:5000(5s)PG_STATEMENT_TIMEOUT_MS:30000(30s)createPgPoolConfigandcreatePgPoolto accept optionalPartial<pg.PoolConfig>overrides.backend/.env.example:backend/src/lib/prisma.ts&backend/prisma/seed.ts:createPgPool().backend/tests/pg-pool.test.ts&backend/tests/integration/stream-lifecycle.test.ts:createPgPool({ connectionString }).Testing
Test Coverage
Test Steps
npm testfrombackend/directory. All 51 test files pass, andpg-pool.tsreaches 100% test coverage.PG_POOL_MAX=25,PG_STATEMENT_TIMEOUT_MS=15000, etc., in.envand runningcreatePgPoolConfig().PG_POOL_MAX=invalidfalls back to default10).Checklist