[HACKERS] DROP SUBSCRIPTION hangs if sub is disabled in the same transaction - Mailing list pgsql-hackers

From Arseny Sher
Subject [HACKERS] DROP SUBSCRIPTION hangs if sub is disabled in the same transaction
Date
Msg-id 87mv6av84w.fsf@ars-thinkpad
Whole thread Raw
Responses Re: [HACKERS] DROP SUBSCRIPTION hangs if sub is disabled in the same transaction
Re: [HACKERS] DROP SUBSCRIPTION hangs if sub is disabled in the sametransaction
List 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



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] Release Note changes
Next
From: Arseny Sher
Date:
Subject: Re: [HACKERS] DROP SUBSCRIPTION hangs if sub is disabled in the same transaction