Conference Schedule - PGConf.EU 2022

Implementing failover of logical replication slots in Patroni

Date: 2022-10-27
Time: 14:40–15:30
Room: Berlin 2+3
Level: Advanced

Logical decoding and replication slots being introduced in PostgreSQL 9.4 (released in 2014) created a solid foundation for implementing built-in core logical replication in version 10 (released in 2017). Unfortunately, there are a few limitations that make logical replication not very useful in real-world scenarios. Logical decoding currently isn’t supported on standby and PostgreSQL allows creating logical replication slots only on the primary. Or in other words, logical slots are lost on failover/switchover.

There have been many attempts to address the problem by Postgres hackers, and most of them without too much success. Although, there is one little function introduced in PostgreSQL 11 that made it possible to implement failover of logical replication slots externally.

In this talk I will tell a story of how Patroni solves the problem of logical replication slots failover without using invasive 3rd party extensions, dig down into some of Postgres internals in order to prove why this approach is safe, and finally, we will discuss limitations and potential downsides of this solution.


Alexander Kukushkin