我有要删除的复制插槽,但是当我删除时,出现了一个我无法从视图中删除的错误。有什么想法吗?
postgres=# SELECT * FROM pg_replication_slots ;
slot_name | plugin | slot_type | datoid | database | active | xmin | catalog_xmin | restart_lsn
--------------+--------------+-----------+--------+----------+--------+------+--------------+-------------
bottledwater | bottledwater | logical | 12141 | postgres | t | | 374036 | E/FE8D9010
(1 row)
postgres=# delete from 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.
postgres=#
答案 0 :(得分:24)
使用pg_drop_replication_slot
:
select pg_drop_replication_slot('bottledwater');
复制槽必须处于非活动状态,即没有活动连接。因此,如果有使用该插槽的流式副本,则必须停止流式副本。或者您可以更改其recovery.conf
,以便它不再使用插槽并重新启动它。
答案 1 :(得分:2)
作为已接受答案的补充,我想提到的是,如果插槽不存在,以下命令也不会失败(这对我很有用,因为我编写了脚本)。
select pg_drop_replication_slot(slot_name) from pg_replication_slots where slot_name = 'bottledwater';