How it works...

Do, or do not; there is no try. If the system outage is serious enough, we do not know the full extent of the damage to system files. If our database was not initialized with file checksums, it might be weeks before corruptions make themselves known. If a crashed server takes over as a primary before that happens, these corruptions could eventually be replicated to other systems.

It's safer to simply start from scratch. Thus our first step is to erase the /db/pgdata directory itself. With no old files to lead Patroni astray, it will rebuild the data by invoking pg_basebackup and configuring the instance as we specified in /etc/patroni/stampede.yml. We can even watch this happen by following the logs.

This is what we should ...

Get PostgreSQL High Availability Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.