Skip to content

fix(db-postgres): release connection back to pool in connectWithReconnect#16893

Open
deepshekhardas wants to merge 1 commit into
payloadcms:mainfrom
deepshekhardas:fix/connection-leak-clean
Open

fix(db-postgres): release connection back to pool in connectWithReconnect#16893
deepshekhardas wants to merge 1 commit into
payloadcms:mainfrom
deepshekhardas:fix/connection-leak-clean

Conversation

@deepshekhardas
Copy link
Copy Markdown
Contributor

Description

The \connectWithReconnect\ function calls \pool.connect()\ to check out a client from the connection pool, attaches an error listener to detect ECONNRESET errors, but never calls
esult.release()\ to return the client back to the pool.

This results in a connection leak where every invocation permanently holds a connection from the pool, eventually causing pool exhaustion.

Fix

Added
esult.release()\ after attaching the error listener. The listener remains active on the pooled connection, so ECONNRESET detection still works when the connection is checked out for actual queries.

Fixes #16772 (connection leak portion)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant