Skip to content

Fixes #1: Prevent Connection Storms and MaxConns Violations in pgxpool - #2

Merged
colmev080 merged 1 commit into
colmev080:mainfrom
venasmitham:fix/issue-1
Aug 6, 2026
Merged

Fixes #1: Prevent Connection Storms and MaxConns Violations in pgxpool#2
colmev080 merged 1 commit into
colmev080:mainfrom
venasmitham:fix/issue-1

Conversation

@venasmitham

Copy link
Copy Markdown

This PR addresses the race condition where multiple goroutines could initiate connection attempts simultaneously, leading to exceeding the MaxConns limit.

Changes:

  • Added inFlightConns to pgxpool.Pool to track pending connection attempts.
  • Updated Acquire logic to check len(conns) + inFlightConns < MaxConns before attempting a new connection.
  • Ensured inFlightConns is decremented on both success and failure of connection establishment.

Fixes #1

@colmev080 colmev080 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR approved via GitBountyCreator automation! Seamless merge and bounty disbursement.

@colmev080
colmev080 merged commit 0ab3342 into colmev080:main Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🎯 Prevent Connection Storms and MaxConns Violations in pgxpool During Recovery

3 participants