1
0

More than 1 year has passed since last update.

[PostgreSQL]ERROR: could not drop replication slot "sub" on publisher: ERROR: replication slot "sub" does not exist

Last updated at Posted at 2023-05-30

PostgreSQLでサブスクリプションを削除しようとしたら以下のエラーが発生しました。
PostgreSQLのVersionは15です。

publicuserdb=# DROP subscription sub ;
ERROR:  could not drop replication slot "sub" on publisher: ERROR:  replication slot "sub" does not exist

SRA OSS Tech Blogのロジカルレプリケーションの紹介 (3)によると、

パブリッシャにレプリケーションスロットが存在しない状態で、サブスクリプションを削除しようとした場合には、下記のようなエラーが出力されます。

second=# DROP subscription logical_sub;
ERROR:  could not drop the replication slot "logical_sub_slot" on publisher
DETAIL:  The error was: ERROR:  replication slot "logical_sub_slot" does not exist

この場合にも、サブスクリプションのレプリケーションスロットを NONE に変更する必要があります。

とのことですので、

publicuserdb=# ALTER SUBSCRIPTION sub SET (slot_name = NONE) ;
ALTER SUBSCRIPTION
publicuserdb=# DROP subscription sub ;
DROP SUBSCRIPTION

として、サブスクリプションを削除できました。

以下はメモです。

そもそもなぜ「パブリッシャにレプリケーションスロットが存在しない状態」になったのか分かりませんでした。
パブリッシャのPostgreSQLを停止して起動したあとにサブスクリプションを削除しようとしたら起こったと思うのですが曖昧なので次に同じようなことがあったら追記しようと思います。

1
0
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0