0

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.

1 Answer 1

1

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
       );
7
  • If lets say i do not create slot, then how much WALs it will preserve? Is it wal_keep_size or min_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 on wal_keep_size. That is the parameter that makes the primary retain old WAL. Replication slots are better. Commented Dec 15, 2022 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.