Re: A proposal to force-drop replication slots to make disabling async/sync standbys or logical replication faster in production environments

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: "Hsu, John" <hsuchen(at)amazon(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: A proposal to force-drop replication slots to make disabling async/sync standbys or logical replication faster in production environments
Date: 2022-06-14 07:50:39
Message-ID: CALj2ACUYBZS5Bt5Og9JRvJKhm11yV8AMaMt6oV6By_sFeGJFsA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jun 10, 2022 at 8:42 PM Hsu, John <hsuchen(at)amazon(dot)com> wrote:
>
> Hi,
>
> Why couldn't you terminate the active_pid associated with the slot you
> want to drop if it's active prior to dropping?

In that case, the slot becomes active immediately after killing the
old walsender because the standby/subscriber opens another connection
with the primary using the same replication slot. The replication slot
will be inactive for a moment during pg_terminate_backend and becomes
active again by the time we call pg_drop_replication_slot and we hit
the same ERROR: replication slot "foo" is active for PID XXXXX.

The idea proposed here is to have a force-drop function that
terminates the walsender gracefully and drops the replication slot
even though there's somebody using it and all of this is done with an
exclusive lock on the slot so that nobody can acquire it while we are
dropping it.

Regards,
Bharath Rupireddy.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2022-06-14 07:53:42 Re: Skipping logical replication transactions on subscriber side
Previous Message Michael Paquier 2022-06-14 07:50:14 Re: Logging query parmeters in auto_explain