如何删除postgres 9.4中的复制槽

Igo*_*nov 21 postgresql replication postgresql-9.4

我有复制插槽,我想删除,但当我删除时,我收到一个错误,我无法从视图中删除.有任何想法吗?

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=#
Run Code Online (Sandbox Code Playgroud)

Cra*_*ger 30

用途pg_drop_replication_slot:

select pg_drop_replication_slot('bottledwater');
Run Code Online (Sandbox Code Playgroud)

查看文档此博客.

复制槽必须处于非活动状态,即没有活动连接.因此,如果有使用该插槽的流式副本,则必须停止流式副本.或者您可以更改它,recovery.conf以便它不再使用插槽并重新启动它.


Yan*_* Vo 5

作为已接受答案的补充,我想提到的是,如果插槽不存在,以下命令也不会失败(这对我很有用,因为我编写了该脚本)。

select pg_drop_replication_slot(slot_name) from pg_replication_slots where slot_name = 'bottledwater';
Run Code Online (Sandbox Code Playgroud)