I'm trying to hunt down what causes replication slots to go inactive. Might seem like a remedial question but I'm noticing that on my master database server, I have many inactive replication slots that are taking up some space on the disk. I know I can just drop inactive slots using the pg_drop_replication_slot(slot_name name) command.
But I'd also like to be able review how we are doing our work / code to see if we are doing something wrong.
If a child server goes offline... from what I've read, it's supposed to just reconnect to the same slot when it comes back up. So not too sure what causes a slot to go inactive.
Here's the query I'm running to see what's what:
widgets=# SELECT slot_name, database, active, pg_xlog_location_diff(pg_current_xlog_insert_location(), restart_lsn) AS retained_bytes widgets-# FROM pg_replication_slots widgets-# WHERE plugin = 'bdr'; slot_name | database | active | retained_bytes --------------------------+--=-------+--------+------------------------ bdr_16385_12345_1_1111__ | widgets | f | 2431628304 bdr_16385_11111_1_1638__ | widgets | f | 2432065824 bdr_16385_22222_1_1638__ | widgets | t | 56 bdr_16385_33333_1_2222__ | widgets | t | 56 bdr_16385_44441_1_1111__ | widgets | f | 2432185336 bdr_16385_55551_1_1111__ | widgets | f | 1133538200 bdr_16385_66661_1_1111__ | widgets | f | 2431950952 bdr_16385_77771_1_1111__ | widgets | f | 2432057320 bdr_16385_88881_1_1111__ | widgets | f | 2331233432 (9 rows) widgets=#
Any comments would be appreciated.