pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Arseny Sher <a.sher@postgrespro.ru>
To: pgsql-hackers@postgresql.org
Subject: Re: DROP SUBSCRIPTION hangs if sub is disabled in the same transaction
Date: Tue, 12 Sep 2017 15:36:46 -0400
Message-ID: <48b251c6-0652-c131-975a-835d8cdb003c@2ndquadrant.com> (raw)
In-Reply-To: <87mv6av84w.fsf@ars-thinkpad>
References: <87mv6av84w.fsf@ars-thinkpad>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

On 9/4/17 10:41, Arseny Sher wrote:
> 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.

I think we are whacking things around a in circle now.  First we moved
the worker killing to the end of the transaction to make subscription
DDL transaction-capable.  Then we changed replication origin dropping to
wait until the worker detaches.  If you do both of these things at once,
you get this circular dependency.

We can break this in any number of ways:

- (your patch) Kill workers right away after ALTER SUBSCRIPTION DISABLE,
thus breaking the appearance of transactional DDL somewhat.

- Revert to the old behavior that the replication origin dropping fails
if it is in use.  Then you would get an error instead of hanging.  But
that was previously also reported as a bug.

- Disallow DROP SUBSCRIPTION in a transaction under certain
circumstances, for example if a transaction has previously manipulated
the same subscription.

- Have DROP SUBSCRIPTION attempt to kill workers if the subscription is
disabled (and possibly, was changed in the same transaction), which
would address this scenario very narrowly.

Maybe there are more ideas.  But I think we have to pick a poison.

Thoughts?

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (32+ messages)  latest in thread

Message-ID: <48b251c6-0652-c131-975a-835d8cdb003c@2ndquadrant.com>
Permalink:  ../48b251c6-0652-c131-975a-835d8cdb003c@2ndquadrant.com/
Also on:    postgresql.org/message-id/48b251c6-0652-c131-975a-835d8cdb003c@2ndquadrant.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: peter.eisentraut@2ndquadrant.com, a.sher@postgrespro.ru
  Subject: Re: DROP SUBSCRIPTION hangs if sub is disabled in the same transaction
  In-Reply-To: <48b251c6-0652-c131-975a-835d8cdb003c@2ndquadrant.com>
  References: <87mv6av84w.fsf@ars-thinkpad> <48b251c6-0652-c131-975a-835d8cdb003c@2ndquadrant.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox