# How Managed PostgreSQL behaves when things fail

What your application sees when a machine, the network, a disk or the database process fails, how long it lasts, whether committed data can be lost, and what the platform tells you.

Unless a table says otherwise, every number on this page was measured on 2026-11-12 on a running
database with 21 GB of data under continuous write load, with the failure injected for real: a
machine powered off at the provider, a network cut, a disk filled, a process killed.

## Terms

| Term                    | Meaning                                                                                                                                                                                                          |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Write downtime**      | The longest time between two successful commits, seen by a client that writes ten times a second through the pooled port of the endpoint and reconnects after every error.                                       |
| **Lost commits (RPO)**  | Commits the client was told had succeeded that are missing afterwards.                                                                                                                                           |
| **Failover**            | A standby becoming the leader because the leader stopped answering. Automatic, and the endpoint follows it.                                                                                                      |
| **Synchronous / async** | Whether a commit on a cluster waits for a standby to have it on disk (`sync`, the default for new clusters) or not (`async`). See [Choose synchronous or asynchronous replication](set-the-replication-mode.md). |
| **Rejoin**              | A machine that was the leader coming back as a replica of the new leader, with its data made consistent with it.                                                                                                 |
| **Health problem**      | A condition the platform checks every two minutes. Past its grace period it is written to **Activity** and mailed to your organization's owners and admins; see [Monitoring](monitoring.md).                     |

## Write an application that survives a failover

- Connect to the endpoint, not to a machine's address. The endpoint follows the leader.
- Reconnect on connection errors and retry the transaction.
- Set a connect timeout (3–5 s) and a statement timeout, so a client does not wait on a machine
  that is gone.
- Expect up to about a minute and a half of failed writes during an unplanned failover under heavy
  write load, and about half a minute during a planned switchover under load.
- If losing the last acknowledged commits is not acceptable, keep the cluster `sync`. `sync` is not
  strict: while no standby is streaming, the leader keeps accepting writes without waiting, and the
  health check reports `sync-degraded` until a standby is back.

## Plan maintenance without downtime

- **Reboot** a cluster, **change its machine type** or **upgrade its minor version**: all three
  move one machine at a time and hand leadership over once, so clients see one switchover (about half a minute of failed writes under load).
- A single node is unavailable for each of these, for about one to one and a half minutes.
- A **major version upgrade** makes a cluster unavailable while the leader's data is upgraded:
  2 min 7 s on a 21 GB cluster under load, with no commit lost. A full backup is taken first, while
  the database still serves.

## Cluster (three machines)

| What fails                                                  | What your application sees                                                                                         | Write downtime        | Lost commits                                                                       | What the platform does and tells you                                                                                                     |
| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | --------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| A replica's machine loses power                             | nothing; throughput dips while the replica catches up                                                              | none (one 2.6 s blip) | 0                                                                                  | the replica rejoins within about a minute                                                                                                |
| The leader's machine loses power, under heavy writes        | writes fail; a standby is promoted after about 37 s, then commits are slow for up to 50 s while it flushes to disk | 30–90 s               | `sync`: 0; `async`: the last commits the standby had not received (11 in one test) | the old leader rewinds and rejoins as a replica by itself, within about 4 minutes                                                        |
| The leader's machine reboots cleanly (provider maintenance) | as above, usually shorter                                                                                          | about 27 s            | 0                                                                                  | the old leader rejoins by itself within about a minute                                                                                   |
| The leader is cut off from the other machines               | writes fail at once; a standby is promoted after about 39 s; the isolated leader stops accepting writes            | about 48 s            | 0                                                                                  | the old leader rejoins when the network is back                                                                                          |
| The failover agent (Patroni) on the leader dies             | nothing; it is restarted within a second and PostgreSQL keeps running                                              | none                  | 0                                                                                  | nothing to report                                                                                                                        |
| A replica stops replicating and does not recover            | nothing                                                                                                            | none                  | 0                                                                                  | after 4 minutes it is restarted; if it still does not stream 6 minutes later, it is rebuilt from the leader; **Activity** says each step |
| A machine is deleted at the provider                        | nothing if it was a replica; a failover if it was the leader                                                       | as above              | as above                                                                           | the health check (every two minutes) sees it gone and recreates it with its name, address and data volume; it rejoins as a replica       |
| You choose **Reboot**                                       | one switchover                                                                                                     | about 33 s            | 0                                                                                  | **Activity** (phase `reboot`) lists each machine                                                                                         |
| Storage grows (automatically or by you)                     | nothing                                                                                                            | none                  | 0                                                                                  | **Activity** says when                                                                                                                   |

**A failover now starts 10 s sooner than in these measurements.** Patroni gives up on a leader that
stopped answering after 20 s (its leader lease, the shortest it allows) instead of the 30 s these
rows were measured with, and existing clusters were moved to it automatically.

## Zones (a cluster spread over de1a and de1b)

Spread is the default since 2026-11-12. Measured on a 3 × performance-4 cluster with 4.5 GB of data, `sync`,
under write load.

| What fails                                                          | What your application sees                                                                                           | Write downtime                           | Lost commits | What the platform does and tells you                                                                         |
| ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------ |
| All of **de1b** (Nuremberg) is lost                                 | nothing; throughput dips while the de1a standby acknowledges every commit                                            | none (one 2.3 s blip)                    | 0            | the de1b member rejoins by itself when the zone is back                                                      |
| All of **de1a** (Falkenstein) is lost                               | writes fail: the de1b member is one of three and does not promote on its own, so no two databases ever accept writes | as long as de1a is down, plus about 70 s | 0            | the cluster comes back by itself when de1a does; the data in de1b is intact throughout                       |
| The leader's machine loses power                                    | writes fail until a standby in **de1a** is promoted (de1a members are preferred)                                     | 32–56 s                                  | 0            | **Activity**: "The leader moved from … to …"; the old leader rejoins by itself                               |
| The leader is in de1b (after a failover that had no de1a candidate) | every commit and query through the endpoint crosses zones                                                            | none                                     | 0            | **Nodes** says so; switch over when convenient (see [Benchmarks](benchmarks.md): about 3 ms more per commit) |

## Single node

| What fails                                 | What your application sees                                                         | Write downtime   | Lost commits | What the platform does and tells you                                                                       |
| ------------------------------------------ | ---------------------------------------------------------------------------------- | ---------------- | ------------ | ---------------------------------------------------------------------------------------------------------- |
| The machine loses power                    | the database is unavailable until the machine is back and PostgreSQL has recovered | about 1 min 45 s | 0            | nothing past the health grace for an outage this short                                                     |
| PostgreSQL crashes                         | the same                                                                           | about 2 minutes  | 0            | it is restarted automatically                                                                              |
| The connection pooler (port 6432) crashes  | connections to 6432 are refused for about 2 s; 5432 is unaffected                  | about 2 s        | 0            | it is restarted automatically                                                                              |
| The disk fills completely in one go        | PostgreSQL stops; writes fail                                                      | several minutes  | 0            | storage grows at once (up to your ceiling) and the database restarts by itself once the filesystem follows |
| Storage grows                              | nothing                                                                            | none             | 0            | **Activity** says when                                                                                     |
| The machine is deleted at the provider     | the database is unavailable                                                        | 3 to 3½ minutes  | 0            | rebuilt on its data volume at its address (phase `repair`)                                                 |
| You change the machine type                | the database is unavailable for one restart                                        | about 80 s       | 0            | **Activity** (phase `resize`)                                                                              |
| You turn logical replication on or off     | one restart of PostgreSQL                                                          | about 15 s       | 0            | **Activity** (phase `replication`): on in about 25 s, off in about 35 s, end to end                        |
| You choose **Reboot**, with a CDC consumer | the database is unavailable for one reboot; the consumer reconnects by itself      | about 54 s       | 0            | the replication slot survives; the consumer received every acknowledged commit                             |

## Recovering data

| What you need                            | How                                                                                 | Measured                                                                                                                                    |
| ---------------------------------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| The database as it was at a given second | [Restore](restore-a-database.md) to a time, into a new database                     | 21 GB restored and serving 7 minutes after the request, exactly to the second asked for                                                     |
| A database you deleted                   | [delete with a final backup](delete-a-database.md); restore it within its retention | final backup and teardown 5 min 44 s; restored as a new cluster in 8 min 21 s, including the last row written two minutes before the delete |

## See what happened

- **Activity** records a change of leader (phase `failover`) within about two minutes, whether a
  failover or a switchover: `The leader moved from <old> to <new> (timeline <n>). Clients reconnect
to the same endpoint.`, followed by what it means for acknowledged commits (none lost when
  replication was `sync` and holding). It also lists a machine being recreated or a replica being
  rebuilt (phase `repair`), storage growth, backups and every health problem.
- **Logs** has each machine's PostgreSQL server log for seven days, including the exact moment of
  the promotion and recovery after a crash.
- **Nodes** shows who leads now, each replica's lag, and whether synchronous replication is holding.

## Related

- [Fail over a cluster](fail-over-a-cluster.md)
- [Monitoring](monitoring.md): the health problems you are mailed about.
- [Troubleshooting](troubleshooting.md)
