When `pg_replication_slots.active` is `false`, it means the replication slot exists but is not currently being actively used by any replication client. Here’s what you need to know:

## What `active = false` means:

1. **Slot exists but is inactive** – The replication slot is defined in the system but no client is currently connected and consuming from it.

2. **WAL retention** – PostgreSQL will continue to retain WAL files needed by this slot (to prevent data loss when the client reconnects).

3. **Disk space concern** – If the slot remains inactive for a long time, WAL files will accumulate and can fill up your disk.

## Common causes:

– **Replication client disconnected** – The consumer (standby, logical replication subscriber, etc.) is not connected
– **Replication paused/stopped** – Replication was intentionally stopped
– **Network issues** – Connection problems between primary and replica
– **Replica down** – The standby server is offline

## How to check:

“`sql
— Check all replication slots
SELECT slot_name, active, pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)) as lag_bytes
FROM pg_replication_slots;

— More detailed view
SELECT
slot_name,
active,
pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn) as lag_bytes,
pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_llsn(), restart_lsn)) as lag_pretty,
wal_status
FROM pg_replication_slots;
“`

## Solutions:

### 1. **If you want to keep the slot:**
– Restart the replication client/consumer
– Check network connectivity
– Ensure the replica service is running
– Verify replication configuration

### 2. **If you want to remove an unused slot:**
“`sql
— Drop the inactive slot (WARNING: irreversible)
SELECT pg_drop_replication_slot(‘your_slot_name’);
“`

### 3. **Monitor WAL growth:**
“`sql
— Check WAL retention for inactive slots
SELECT
slot_name,

pg_replication_slots active false

active,
pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)) as retained_wal
FROM pg_replication_slots
WHERE NOT active;
“`

## Important warnings:

⚠️ **Don’t let inactive slots accumulate WAL indefinitely** – This can lead to disk full situations.

pg_replication_slots active false

⚠️ **Only drop slots if you’re sure they’re not needed** – Dropping a slot that a standby will try to reconnect to will break replication permanently.

⚠️ **For logical replication slots** – Inactive logical slots can also prevent VACUUM from cleaning up dead tuples, leading to table bloat.

Would you like help troubleshooting why your specific replication slot is inactive, or do you need guidance on managing disk space from accumulated WAL?

Share this post

Related posts