Skip to content

[Bug]: local connections to a stuck postmaster never time out #11722

Closed

Description

@armru

Is there an existing issue already for this bug?

  • I have searched for an existing issue, and could not find anything. I believe this is a new bug.

I have read the troubleshooting guide

  • I have read the troubleshooting guide and I think this is a new bug.

I am running a supported version of CloudNativePG

  • I have read the troubleshooting guide and I think this is a new bug.

Contact Details

No response

Version

trunk (main)

What version of Kubernetes are you using?

1.37

What is your Kubernetes environment?

Self-managed: kind (evaluation)

How did you install the operator?

YAML manifest

What happened?

The instance manager opens its local connections to PostgreSQL with no timeout. These are the superuser and metrics exporter pools, where every query opens a new connection, and the WAL archive check that runs before an in-tree backup. When the postmaster is stopped or stuck, its Unix socket still accepts connections but nobody answers the startup message, so every caller blocks forever.

The /pg/status endpoint polled by the operator is one of these callers. On a KIND cluster running #11358, with the primary's postmaster stopped with SIGSTOP, a goroutine dump of the instance manager shows the pgStatus handlers blocked in pgconn.connectOne. When the instance manager decides to exit, the :8000 web server waits for these handlers until the controller manager gives up 30 seconds later, and the primary lease is released 30 seconds late. A backup request on the local web server hangs the same way, in the WAL archive check.

I expected these connection attempts to fail after a bounded time, as the connections to the primary already do with connect_timeout=5.

Cluster resource

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: cluster-example
  annotations:
    alpha.cnpg.io/enableInstancePprof: "true"
spec:
  instances: 3
  storage:
    size: 1Gi

Relevant log output

goroutine 3875 [IO wait]:
...
github.com/jackc/pgx/v5/pgconn.(*PgConn).receiveMessage(0x57a121ddcb08)
	$GOMODCACHE/github.com/jackc/pgx/[email protected]/pgconn/pgconn.go:667 +0x2c
github.com/jackc/pgx/v5/pgconn.connectOne({0x39bb158, 0x3ad4be0}, 0x57a12217ad00, 0x57a121e9c980, 0x0)
	$GOMODCACHE/github.com/jackc/pgx/[email protected]/pgconn/pgconn.go:435 +0xb90
...
database/sql.(*DB).QueryRow(0x57a1218b0000?, {0x19db094?, 0x57a121e718a8?}, {0x57a121e71940?, 0x57a121e718b8?, 0xffff40467968?})
	$GOROOT/src/database/sql/sql.go:1861 +0x48
github.com/cloudnative-pg/cloudnative-pg/pkg/management/postgres.(*Instance).GetStatus(0x57a1218b0000)
	pkg/management/postgres/probes.go:82 +0x170
github.com/cloudnative-pg/cloudnative-pg/pkg/management/postgres/webserver.(*remoteWebserverEndpoints).pgStatus(0xffff871dcad8?, {0x39b8960, 0x57a12153b860}, 0x57a1218deb44?)
	pkg/management/postgres/webserver/remote.go:324 +0x2c

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    bug 🐛
    on Oct 22, 2026
  2. self-assigned this
    on Oct 22, 2026
  3. added 2 commits that reference this issue on Oct 23, 2026
    bdb2fff
    177af2f
  4. added a commit that references this issue on Oct 23, 2026
    21e24f6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐛

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions