cannot delete from view pg_replication_slots

In this article, we will see solution for the error “cannot delete from view pg_replication_slots”.

ERROR: cannot delete from view "pg_replication_slots" DETAIL: Views that do not select from a single table or view are not automatically updatable. HINT: To enable deleting from the view, provide an INSTEAD OF DELETE trigger or an unconditional ON DELETE DO INSTEAD rule.

cannot delete from view pg_replication_slots


Solution to cannot delete from view pg_replication_slots:
Do not let the inactive slots stay because the master will retain the WAL files needed by the inactive slot indefinitely and will fill up space in the disk.

Following command used to delete a replication slot:

select pg_drop_replication_slot('pgslave');

Alternatively we can use following full command.

select pg_drop_replication_slot(slot_name) from pg_replication_slots where slot_name = 'pgslave';