DROP SUBSCRIPTION hangs if sub is disabled in the same transaction

From: Arseny Sher <a(dot)sher(at)postgrespro(dot)ru>
To: pgsql-hackers(at)postgresql(dot)org
Subject: DROP SUBSCRIPTION hangs if sub is disabled in the same transaction
Date: 2017-09-04 14:41:19
Message-ID: 87mv6av84w.fsf@ars-thinkpad
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

Currently, DROP SUBSCRIPTION on REL_10_STABLE would block forever in the
following setup:

node 1:
create table t (i int);
create publication p for table t;

node 2:
create table t (i int);
create subscription s CONNECTION 'port=5432' publication p;
begin;
alter subscription s disable ;
alter subscription s set (slot_name = none);
drop subscription s;
end;

It hangs in replorigin_drop because we wait until ReplicationState is
released. This should happen on exit of worker, but worker will not exit
until transaction commit because he doesn't see that the sub was
disabled.

Attached patch fixes this by stopping workers before RO drop, as
already done in case when we drop replication slot. I am not sure
whether this is a proper solution, but for now I don't see any problems
with early stop of workers: even if transaction later aborts, launcher
will happily restart them, isn't it?

--
Arseny Sher
Postgres Professional: https://postgrespro.ru
The Russian Postgres Company

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Arseny Sher 2017-09-04 14:43:09 Re: DROP SUBSCRIPTION hangs if sub is disabled in the same transaction
Previous Message Tom Lane 2017-09-04 14:33:08 Re: Release Note changes