【问题标题】:How to delete replication slot in postgres 9.4如何在 postgres 9.4 中删除复制槽
【发布时间】:2015-08-31 12:38:29
【问题描述】:

我有想要删除的复制槽,但是当我删除时,我收到了一个无法从视图中删除的错误。有什么想法吗?

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=#

【问题讨论】:

  • 我找到了命令 pg_drop_replication_slot(slot_name name) postgresql.org/docs/9.4/static/… 但是当我做 postgres=# select * from pg_drop_replication_slot('bottledwater');我得到了错误:复制槽“瓶装水”已经处于活动状态

标签: postgresql replication postgresql-9.4


【解决方案1】:

使用pg_drop_replication_slot:

select pg_drop_replication_slot('bottledwater');

参见the docsthis blog

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

【讨论】:

  • 嗯...博客的链接似乎没有了。
  • 博客文章现在可以在这里找到:paquier.xyz/postgresql-2/…
  • 我也不能放在主服务器上...错误是错误:复制槽不存在 select * from pg_replication_slots 什么都不返回。
【解决方案2】:

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

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

【讨论】:

    猜你喜欢
    • 2020-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    相关资源
    最近更新 更多