DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · Replication / Sending Servers

idle_replication_slot_timeout

Sets the duration a replication slot can remain idle before it is invalidated.

  • Default: 0
  • Type: integer (s)
  • Range: 0 … max (2147483647)
  • Applies: Reload

In plain words

A replication slot nobody uses any more still forces the server to keep WAL and old row versions. New in PostgreSQL 18, idle_replication_slot_timeout automatically invalidates a slot that has had no consumer connected for longer than this time.

The default 0 disables it. It complements max_slot_wal_keep_size: one limits by age, the other by size.

For DBAs and operators

Idle time is measured from pg_replication_slots.inactive_since (PostgreSQL 17+), and the check runs during checkpoints, so invalidation can happen up to checkpoint_timeout later than the exact limit (run CHECKPOINT to force it).

LOG: invalidating obsolete replication slot "sub1"
DETAIL: The slot's idle time of 3605s exceeds the configured "idle_replication_slot_timeout" duration of 3600s.

The slot then has invalidation_reason = 'idle_timeout'. Not affected: slots that do not reserve WAL, and synced failover slots on a standby (synced = true), which are always "inactive" there.

SELECT slot_name, active, inactive_since, invalidation_reason
  FROM pg_replication_slots ORDER BY inactive_since;

Set it longer than any planned maintenance window of your standbys and subscribers (a weekend shutdown of a reporting subscriber should not cost a full resync). Units are seconds when unspecified; values like '2d' work.

How to change it

Change in postgresql.conf or ALTER SYSTEM, then run SELECT pg_reload_conf().

See it in context

Replication slots Logical replication

Related parameters

max_slot_wal_keep_size max_replication_slots checkpoint_timeout

All Replication parameters