Postgre sql connection pool#94
Merged
elizabetheonoja-art merged 2 commits intoJul 18, 2026
Merged
Conversation
…alth-probe Add PostgreSQL pool health probe with adaptive sizing
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.
Motivation
Provide a lightweight, reusable PostgreSQL health probe to detect latency and pressure and recommend adaptive pool sizing for services that rely on DB-backed ingestion and settlement.
Meet critical-path performance/availability goals by measuring rolling P99 latency and preventing pool oscillation with a cooldown.
Description
Add PostgresPoolHealthProbe (meter-simulator/src/postgres-pool-health.js) that runs bounded probes, records rolling latency samples, computes utilization and P99, and produces sizing recommendations (scale_up/scale_down/hold).
Expose environment-configurable defaults in meter-simulator/src/config.js under postgresql for probe SQL, timeouts, P99 target, min/max pool size, scale thresholds, and cooldown.
Add unit tests (meter-simulator/tests/postgres-pool-health.test.js) covering healthy probes, probe failures, scale-up/scale-down recommendations, and cooldown-protected sizing application.
Document architecture, configuration variables, example usage, monitoring/alerting guidance, and a runbook in meter-simulator/README.md.
Testing
Ran the new probe test suite with npm test -- --runInBand tests/postgres-pool-health.test.js, and it passed (5 passed).
Ran the full test suite with npm test -- --runInBand; the new probe tests pass but the overall run fails due to pre-existing unrelated failures in meter-device.test.js (examples: bad secret key size from NaCl signing, a peak-hour timestamp expectation mismatch, and a signature message length expectation mismatch).
Closes #64