Diagnostic Queries
Symptoms
An operation (e.g. dropping a slot) failed because the replication slot is currently in use by another process. PostgreSQL raises SQLSTATE 55006 (object_in_use).
- The slot is actively held by a connected consumer.
- Common when trying to drop a slot still in use.
- The holding PID is shown.
What the server log shows
ERROR: replication slot "standby_1" is active for PID 4242
Why PostgreSQL raises this — what the manual says
As Section 26.2.6 Replication Slots explains:
The operation (such as dropping the slot) failed because a walsender is currently connected to it; a slot in active use cannot be modified or dropped until the consuming standby or client disconnects.
A slot is exclusive to one active consumer connection. Attempting to drop or otherwise exclusively use a slot another process holds conflicts with that ownership, so PostgreSQL reports 55006.
Common causes
- Dropping a slot while a consumer is still connected.
- A standby/logical consumer holding the slot.
- A stuck or zombie connection retaining the slot.
How to fix it
- Stop the consumer holding the slot, then retry.
- Identify and terminate the holding backend if necessary:
SELECT pg_terminate_backend(4242);(with caution). - Wait for the active consumer to disconnect before dropping.
Related & next steps
Reference: PostgreSQL 18 Section 27.2 “Log-Shipping Standby Servers”.
Thanks — noted. This helps keep the database accurate.