Postgresql – change the wal_level from logical to replica? If so are any impact on the replication process

postgresqlpostgresql-11replication

Is there a chance to change the wal_level from logical to replica without any impact. I know this involves a restart of services but is this possible?
For example if there is a already a logical replication running with master and slave setup. The question here is can I change the wal_level now from logical to replica(streaming) with the same master and slave.

Best Answer

At least in Postgres 11 you can restart, but wal_level does not change if you have slots. You should drop the slots first to do the change (not only subscriptions and publications), losing the replicas.

So if you want to change the wal_level, first you could list the slots:

select * from pg_replication_slots;

and then, drop the slots:

select pg_drop_replication_slot('the_name_of_subscriber');

for each slot.

Once you drop all slots and change the the wal_level to replica, you can't make replicas. Even pg_wal is flushed when data gets old, maybe a couple of minutes after the drop, it doesn't even wait for the reboot.