简体   繁体   English

无法从 PostgresQL 删除订阅

[英]Cannot Drop Subscription from PostgresQL

I'm using pgAdmin and can't delete the subscriptions in the database or drop the database.我正在使用 pgAdmin 并且无法删除数据库中的订阅或删除数据库。

When I attempt to drop the database I receive the error message当我尝试删除数据库时,我收到错误消息

ERROR: database "xxxx" is being used by logical replication subscription DETAIL: There are 4 subscriptions.

When I attempt to drop the subscriptions I receive当我尝试删除收到的订阅时

ERROR: could not drop the replication slot "xxxx" on publisher DETAIL: The error was: ERROR: replication slot "xxxx" does not exist

I receive 0 results when querying for replication slots查询复制槽时收到 0 个结果

select * from pg_replication_slots

When I query for subscriptions they all show up当我查询订阅时,它们都会出现

SELECT * FROM pg_subscription

Any help much appreciated!非常感谢任何帮助!

Unfortunately, you have to go through this elaborate dance:不幸的是,您必须通过这个精心制作的舞蹈来 go:

alter subscription <sub1> disable;
alter subscription <sub1> set (slot_name = none);
drop subscription <sub1>;

for each subscription, before you can drop the database.对于每个订阅,在您可以删除数据库之前。

I think the justification for this monstrosity is they want to make it really hard to drop a subscription without also dropping the slot it services on the publisher.我认为这种怪物的理由是他们希望在不放弃它在发布者上服务的插槽的情况下很难放弃订阅。 You can do it, you just have to go two steps out of your way, for each subscription.你可以做到,你只需要 go 两个步骤,每次订阅。

I faced the similar issue.我遇到了类似的问题。 Connect to the database连接到数据库

psql your_db;

and then接着

drop subscription my_subscription;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM