I have PostgreSQL streaming replication setup using replication slot. Node1 is primary and Node2 is slave. Now, node1 is down and promoted node2. Node2 is running and in read-write mode. There is heavy load on node2 now. How i can make sure enough WALs getting preserved on node2, so that when node1 joins, it could do diff sync using pg_rewind
. This is PostgreSQL 14. There is no WAL archiving setup.
Add a comment
|
1 Answer
For that, you'd have to create a replication slot on Node2 during failover:
SELECT pg_create_physical_replication_slot(
slot_name => 'slot',
immediately_reserve => TRUE
);
-
If lets say i do not create slot, then how much WALs it will preserve? Is it
wal_keep_size
ormin_wal_size
? Commented Dec 15, 2022 at 9:04 -
wal_keep_size
.min_wal_size
is about WAL for the future, not old WAL. Commented Dec 15, 2022 at 9:13 -
Don't we need to preserve the newer WAL after the promotion on new primary so that pg_rewind works correctly? Commented Dec 15, 2022 at 9:26
-
Here, default value for min_wal_size is just 80MB and i have heavy workload on promoted primary. I want to preserve at least 1GB of newer workload or WAL on newer primary without creating slot. What should be values for wal_keep_size and min_wal_size in this case? Commented Dec 15, 2022 at 9:29
-
I'm not talking about recent WAL in the context of
min_wal_size
, I am talking about future WAL. Please read the documentation onwal_keep_size
. That is the parameter that makes the primary retain old WAL. Replication slots are better. Commented Dec 15, 2022 at 10:00