For AI agents: this documentation is indexed for you in llms.txt, and all of it in /llms.txt. Every page is also available as markdown: append .md to its address.

Troubleshoot using Patroni

To be sure that the PostgreSQL cluster is up and running and replication is in sync, you can use PatroniOpens in a new tab, which runs inside every PostgreSQL instance deployed by the Cennso PostgreSQL Instance. Patroni has no user interface. You inspect the cluster with the patronictl utility inside a PostgreSQL pod.

To check the state of the PostgreSQL cluster, execute the following steps:

  1. List the PostgreSQL pods in the cluster. The operator labels every pod with its current role, so you can see the primary and the replicas:

    bash

    The ROLE column shows primary for the primary and replica for the replicas. The postgres-operator.crunchydata.com/instance label limits the list to the PostgreSQL pods.

  2. Run patronictl list inside the database container of any PostgreSQL pod:

    bash

    The output lists every member of the cluster with its role, state, timeline, and replication lag. For example, for a PostgreSQLInstance named pg-instance:

    text

    A healthy cluster shows exactly one Leader in the running state and every replica in the streaming state with both Lag columns close to 0. The first Lag column shows how far the replica is behind in receiving the WAL from the primary, and the second one shows how far it is behind in replaying it. All members share the same timeline in the TL column. A replica in the stopped or start failed state, a growing lag, or a member on an older timeline points to a replication problem.

  3. If a member is unhealthy, read the Patroni and PostgreSQL logs of its pod:

    bash

Switch the primary to another replica

Patroni promotes a replica automatically when the primary becomes unavailable, so no manual action is required. A manual switchover is useful when the primary is healthy, but you want to move it, for example before you drain the node that runs it for maintenance.

A switchover is a controlled role change. Patroni makes the chosen replica the new primary, and the old primary joins the cluster again as a replica. Client connections through PgBouncerOpens in a new tab are interrupted for a few seconds while the roles change.

To switch the primary to another replica, execute the following steps:

  1. List the members of the cluster and note the names of the current primary and of the replica you want to promote:

    bash

    Choose a replica in the streaming state with a lag of 0, so that no committed transactions are lost during the switchover.

  2. Run the switchover from any PostgreSQL pod. The --force option skips the interactive confirmation:

    bash

    Replace the following placeholders with the member names from step 1:

    • {CURRENT-PRIMARY-MEMBER} - the member shown as Leader
    • {REPLICA-MEMBER} - the member you want to promote

    To run the switchover at a later time, add --scheduled {TIMESTAMP} with an ISO 8601 timestamp, for example 2026-10-05T22:00:00+00:00.

  3. Check the result. The chosen replica is now the Leader, the former primary is a Replica in the streaming state, and the timeline in the TL column increased by one:

    bash

The operator updates the role labels of the pods and the primary Service after the switchover, so clients keep connecting through the same endpoints.