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

Posted 瀚高PG实验室

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了逻辑复制环境删除订阅报错 replication slot does not exist相关的知识,希望对你有一定的参考价值。

瀚高数据库
目录
环境
症状
问题原因
解决方案

环境
系统平台: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

以上是关于逻辑复制环境删除订阅报错 replication slot does not exist的主要内容,如果未能解决你的问题,请参考以下文章