test=# drop subscription test_slot_sub ;ERROR: could not connect to publisher when attempting to drop the replication slot "test_slot_sub"DETAIL: The error was: could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5433? HINT: Use ALTER SUBSCRIPTION ... SET (slot_name = NONE) to disassociate the subscription from the slot.test=#
test=# drop subscription test_slot_sub ;ERROR: could not drop the replication slot "test_slot_sub" on publisher DETAIL: The error was: ERROR: replication slot "test_slot_sub" does not exist test=#
- 当删除与远程主机(正常状态)上的复制槽相关联的订阅时,DROP SUBSCRIPTION 将连接到远程主机,并尝试删除该复制槽,作为其操作的一部分。这是必要的, 以便释放远程主机上为订阅分配的资源。如果失败,因为远程主机不可访问, 或者因为远程复制槽不能被删除,或者复制槽不存在或从不存在, 则DROP SUBSCRIPTION命令将失败。要在这种情况下继续, 请执行ALTER SUBSCRIPTION … SET (slot_name = NONE) 来解除复制槽与订阅的关联。之后,DROP SUBSCRIPTION 将不再尝试对远程主机执行任何操作。请注意,如果远程复制槽仍然存在, 则应手动删除该插槽;否则将继续保留WAL,最终可能导致磁盘空间不足
alter subscription test_slot_sub disable;ALTER SUBSCRIPTION test_slot_sub SET (slot_name = NONE);drop subscription test_slot_sub ;
每一个(活跃的)订阅会从远(发布)端上的一个复制槽接收更改。通常,远程复制槽是在使用CREATE SUBSCRIPTION创建订阅是自动创建的,并且在使用DROP SUBSCRIPTION删除订阅时,复制槽也会自动被删除。不过,在一些情况下,有必要单独操纵订阅以及其底层的复制槽。如下场景:
ref
Replication Slot Management
ref
复制槽管理