Making use of replication slots
Now that I’ve introduced synchronous replication and dynamically adjustable durability, I want to focus on a feature called replication slots.
What’s the purpose of a replication slot? Let’s consider the following example – there’s a primary and a replica. On the primary, a large transaction is executed, and the network connection isn’t fast enough to ship all the data in time. At some point, the primary removes its transaction log (checkpoint). If the replica is too far behind, a resync is needed. As we’ve already seen, the wal_keep_size
setting can be used to reduce the risk of failing replication. The question is, what’s the best value for the wal_keep_size
setting? Sure, more is better, but how much is best?
Replication slots will solve this problem for us – if we’re using a replication slot, a primary can only recycle the transaction log once it’s been consumed by...