cancel
Showing results for 
Search instead for 
Did you mean: 

Replication slot not able to keep archives if slot is inactive

Adventurer

Replication slot not able to keep archives if slot is inactive

Hello ,

 

I am testing one senerio releated to replication slot(Which i need to implement on PROD)

 

I tried to configure streaming replication with replication slot.

 

My-configuration -

 

Master - Server-side configuration -->

 

archive_mode=on
archive_command='/bin/true'
wal_level=replica

max_wal_senders = 10

max_replication_slots=10

wal_keep_segments = 10

 

And Created replication slot "SELECT * FROM pg_create_physical_replication_slot('test1');"

 

Slave-side configuration -->

 

primary_slot_name='test1'
standby_mode = 'on'
primary_conninfo = 'user=postgres port=5432 sslmode=prefer sslcompression=1 krbsrvname=postgres target_session_attrs=any'


Issues -

 

When i bring down replica and insterted near about 300MB data to check will server keep transaction files in <PGDATA>/pg_wal till replication slot become active .But files get removed when replication slot is in inactive state,Can you please explain if this is the expected ? 


PG-Version - psql (PostgreSQL) 10.10

 

3 REPLIES 3
Level 2 Adventurer

Re: Replication slot not able to keep archives if slot is inactive

Hi,

 

Maybe you should check two system catalogs pg_stat_replication and pg_replication_slots to make sure your streaming replication setup works properly before inserting data.

 

Besides, you should check both DB logs of master and standby DBs. There should be some clue on why your setting does not work.

Adventurer

Re: Replication slot not able to keep archives if slot is inactive

Hi Alex ,

While testing I bring down the replica which broke the replication and also verified the status with the help of catalog view


pg_stat_replication - return 0 record
pg_replication_slot - show slot is inactive .

After that I have inserted data to check.

Also,In the database logs there is no nothing as such.
EDB Team Member

Re: Replication slot not able to keep archives if slot is inactive

Hi @ankitadba,

 

This is not the expected behavior, if you have replication slot, it will not recycle the WAL's which are needed by the standby.

I have also tested the same on the PG 10, it holds the WAL files needed for the standby.

 

Could you please share the below details :

 

- File list in the $PGDATA/pg_wal
- The output of the select * from pg_stat_replication and select * from pg_replication_slots from the Master
- Recovery.conf file details from the standby

 

Then stop the standby cluster and insert some data to generate enough WAL files.

 

- Capture the above-mentioned details again.

 

Then, start the standby server and check whether it is catching up with the Master. If it is not catching up, then share the above-gathered details.

 

Regards,

Sudhir