Repository navigation
fix(instance-manager): add a connect timeout to the local connections - #11718
Merged
Merged
Conversation
Contributor
|
❗ By default, the pull request is configured to backport to all release branches.
|
Member
Author
|
/test |
Contributor
|
@armru, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/39635204125 |
armru
force-pushed
the
dev/local-pool-connect-timeout
branch
from
October 22, 2026 09:13
aa9214e to
e86b090
Compare
leonardoce
force-pushed
the
dev/local-pool-connect-timeout
branch
from
October 23, 2026 10:28
e86b090 to
a2c3801
Compare
Contributor
|
/test |
Contributor
|
@leonardoce, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/39939350142 |
leonardoce
approved these changes
Oct 23, 2026
mnencia
approved these changes
Oct 23, 2026
…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 <[email protected]>
The check that runs before an in-tree backup opens its own local connection, outside the pools, so a stuck postmaster held the backup request on the local web server forever. Signed-off-by: Armando Ruocco <[email protected]>
mnencia
force-pushed
the
dev/local-pool-connect-timeout
branch
from
October 23, 2026 13:23
a2c3801 to
a2b693e
Compare
Signed-off-by: Marco Nenciarini <[email protected]>
cnpg-bot
pushed a commit
that referenced
this pull request
Oct 23, 2026
…#11718) 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. The check that runs before an in-tree backup opens its own local connection and has the same problem, holding the backup request forever. This sets `connect_timeout=5` on these connections, 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. A TCP user timeout would not help: these connections go through the Unix socket, and even over TCP the kernel keeps acknowledging the data sent to a stopped postmaster. Closes #11722 Signed-off-by: Armando Ruocco <[email protected]> Signed-off-by: Marco Nenciarini <[email protected]> Co-authored-by: Marco Nenciarini <[email protected]> (cherry picked from commit 21e24f6)
cnpg-bot
pushed a commit
that referenced
this pull request
Oct 23, 2026
…#11718) 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. The check that runs before an in-tree backup opens its own local connection and has the same problem, holding the backup request forever. This sets `connect_timeout=5` on these connections, 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. A TCP user timeout would not help: these connections go through the Unix socket, and even over TCP the kernel keeps acknowledging the data sent to a stopped postmaster. Closes #11722 Signed-off-by: Armando Ruocco <[email protected]> Signed-off-by: Marco Nenciarini <[email protected]> Co-authored-by: Marco Nenciarini <[email protected]> (cherry picked from commit 21e24f6)
armru
added a commit
that referenced
this pull request
Nov 17, 2026
The timeout added by #11718 is `connect_timeout=5`, which bounds the connection attempt and not a connection that is already open. Signed-off-by: Armando Ruocco <[email protected]>
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.
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
pgStatushandlers blocked inpgconn.connectOne. At shutdown the:8000web server waits for them until the controller manager gives up 30 seconds later, which delays the release of the primary lease by as much. The check that runs before an in-tree backup opens its own local connection and has the same problem, holding the backup request forever.This sets
connect_timeout=5on these connections, 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. A TCP user timeout would not help: these connections go through the Unix socket, and even over TCP the kernel keeps acknowledging the data sent to a stopped postmaster.Closes #11722