Re: Need Force flag for pg_drop_replication_slot() - Mailing list pgsql-hackers

From Simon Riggs
Subject Re: Need Force flag for pg_drop_replication_slot()
Date
Msg-id CANP8+jLpQy7Uo8YbSSCywv1MHJhXJBxfym00qOugRcgDrxCQHg@mail.gmail.com
Whole thread Raw
In response to Need Force flag for pg_drop_replication_slot()  (Josh Berkus <josh@agliodbs.com>)
List pgsql-hackers
On 29 May 2015 at 18:15, Josh Berkus <josh@agliodbs.com> wrote:
 
pg_drop_replication_slot() can be a time-critical function when the
master is running out of disk space because the replica is falling
behind.  So I was a little startled by this:

cio=# select
pg_drop_replication_slot('bdr_24577_6147720645156311471_1_25383__');
ERROR:  replication slot "bdr_24577_6147720645156311471_1_25383__" is
already active

You have to first terminate the replication connection before you can
delete the slot ... and do it fast enough that the replica doesn't
reconnect before you drop the slot.

Why would you not stop the receiver first, then drop the slot?

Dropping the slot destroys any chance you have of recovering the downstream server, so should not be done lightly.

That sounds like a critical fail to me, so making it easier to do that doesn't sound cool. I oppose this suggestion.
 
While I'm just doing this during testing, it could be a critical fail in
production.  I think the simplest way to resolve this would be to add a
boolean flag to pg_drop_replication_slot(), which would terminate the
replication connection and delete the slot as a single operation.

If you really want it you can write a function to do that for private use.
 
--
Simon Riggs                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: RFC: Remove contrib entirely
Next
From: Peter Geoghegan
Date:
Subject: Re: Re: 9.5 release notes may need ON CONFLICT DO NOTHING compatibility notice for FDW authors