逻辑复制环境删除订阅报错 replication slot does not exist

时间:2021-09-19 00:58:54

瀚高数据库

目录

环境

症状

问题原因

解决方案


环境

系统平台:N/A

版本:4.5.7


症状

删除订阅时报错:

highgo=# drop subscription test2_sub ;       
ERROR: could not drop replication slot "test2_sub" on publisher: ERROR: replication slot "test2_sub" does not exist


问题原因

当删除订阅时,DROP SUBSCRIPTION操作将连接到逻辑复制的主库上清理绑定的复制槽,如果相关复制槽未被发现,则执行DROP SUBSCRIPTION命令时将会报错。

这种情况说明该订阅使用到的复制槽已被各种原因删除。


解决方案

需要解除复制槽与订阅的绑定关系。

highgo=# alter subscription test2_sub set (slot_name =none);
ALTER SUBSCRIPTION

如果订阅状态为enable,需要先disable,然后再解除绑定:

highgo=#  alter subscription test2_sub disable;
ALTER SUBSCRIPTION
highgo=# alter subscription test2_sub set (slot_name =none);
ALTER SUBSCRIPTION


否则会报错:

highgo=# alter subscription test2_sub set (slot_name =none);
ERROR: cannot set slot_name = NONE for enabled subscription