There's more...

Relying on the tail command is an old standby method that's frequently useful in watching logs. Unfortunately we also need to know which server won the leader race to know which logs to observe. We could use the list parameter for patronictl, yet the takeover process relies on several timeouts. The authors of Patroni considered this and added a -w flag to "watch" the command by running it upon a configurable interval.

This means we could observe the failover and takeover as it happened with a command like this:

patronictl list -w 5 -d pg1:2379 stampede

Of course, this isn't really a novel feature. It's extremely likely most Linux systems have the watch command installed, and it fills the same role. We could get the same ...

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.