fix(instance-manager): add a connect timeout to the local connection pools by armru · Pull Request #11718 · cloudnative-pg/cloudnative-pg · GitHub
Skip to content

fix(instance-manager): add a connect timeout to the local connection pools - #11718

Open
armru wants to merge 1 commit into
mainfrom
dev/local-pool-connect-timeout
Open

armru wants to merge 1 commit into
mainfrom
dev/local-pool-connect-timeout

Conversation

@armru

@armru armru commented Oct 21, 2026

Copy link
Copy Markdown
Member

The superuser and metrics exporter pools connect to PostgreSQL with no timeout, and every query opens a new connection. When the postmaster is stopped or stuck, its socket still accepts connections but never answers the startup message, so every caller blocks for good. The instance status endpoint polled by the operator is one of them. On a KIND cluster with the primary's postmaster stopped with SIGSTOP, a goroutine dump shows the pgStatus handlers blocked in pgconn.connectOne. At shutdown the :8000 web server waits for them until the controller manager gives up 30 seconds later, which delays the release of the primary lease by as much.

This sets connect_timeout=5 on both pools, as the connections to the primary already do. With #11358 applied, the same scenario releases the lease 5 seconds after the instance manager decides to exit, instead of 30.

…pools

When the postmaster is stuck, a new local connection is accepted but
never answered, so the caller hangs forever. The status endpoint is one
such caller, and on shutdown the web server waits for it until the
manager gives up after 30 seconds, delaying the release of the primary
lease.

Use connect_timeout=5, as we already do for the primary.

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
@armru
armru requested a review from a team as a code owner October 21, 2026 16:27
@github-actions

Copy link
Copy Markdown
Contributor

@cnpg-bot cnpg-bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.28 release-1.30 labels Oct 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

❗ By default, the pull request is configured to backport to all release branches.

  • To stop backporting this pr, remove the label: backport-requested ◀️ or add the label 'do not backport'
  • To stop backporting this pr to a certain release branch, remove the specific branch label: release-x.y

@armru

armru commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

/test

@github-actions

Copy link
Copy Markdown
Contributor

@cnpg-bot cnpg-bot added the ok to merge 👌 This PR can be merged label Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-requested ◀️ This pull request should be backported to all supported releases ok to merge 👌 This PR can be merged release-1.28 release-1.30

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants