Re: DROP SUBSCRIPTION hangs if sub is disabled in the same transaction

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Arseny Sher <a(dot)sher(at)postgrespro(dot)ru>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: DROP SUBSCRIPTION hangs if sub is disabled in the same transaction
Date: 2017-09-13 04:07:31
Message-ID: CAD21AoCUiYJU_auS=1GqqFbr5Q2GwQc4dBLJa_gS-+ex_RYYJQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Sep 13, 2017 at 12:48 AM, Arseny Sher <a(dot)sher(at)postgrespro(dot)ru> wrote:
> Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> writes:
>
>> FWIW, perhaps we can change the replication origin management so that
>> DROP SUBSCRIPTION doesn't drop the replication origin and the apply
>> worker itself removes it when exit. When an apply worker exits it
>> removes the replication origin if the corresponding subscription had
>> been removed.
>

After thought, I think we can change it like followings.
* If the replication origin is not acquired, DROP SUBSCRIPTION can drop it.
* If the replication origin is acquired by someone DROP SUBSCRIPTION
takes over a job of dropping it to the apply worker.
* The apply worker drops the replication origin when exit if the apply
worker has to drop it.

> I don't think this is reliable -- what if worker suddenly dies without
> accomplishing the job?

The apply worker will be launched by the launcher later. If DROP
SUBSCRIPTION is issued before the apply worker launches again, DROP
SUBSCRIPTION itself can remove the replication origin.

Attached a very rough patch for reference. It's very ugly but we can
deal with this case.

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachment Content-Type Size
very_rough_repl_origin.patch text/x-patch 5.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2017-09-13 04:09:41 Re: why not parallel seq scan for slow functions
Previous Message Tom Lane 2017-09-13 04:05:19 Re: Setting pd_lower in GIN metapage