Re: Refreshing subscription relation state inside a transaction block

From: Petr Jelinek <petr(dot)jelinek(at)2ndquadrant(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Refreshing subscription relation state inside a transaction block
Date: 2017-06-15 06:41:16
Message-ID: dea97819-b6e6-bb57-bd78-14c6946b0547@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 13/06/17 18:33, Masahiko Sawada wrote:
> On Wed, Jun 14, 2017 at 1:02 AM, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>> On Tue, Jun 13, 2017 at 4:53 PM, Petr Jelinek
>> <petr(dot)jelinek(at)2ndquadrant(dot)com> wrote:
>>> On 13/06/17 09:06, Masahiko Sawada wrote:
>>>> Hi,
>>>>
>>>> The commit ddd7b22b225ae41d16ceb218b387645cb9becfdc makes table sync
>>>> workers stop when subscription relation entry is removed. It doesn't
>>>> work fine inside transaction block. I think we should disallow to use
>>>> the following subscription DDLs inside a transaction block. Attached
>>>> patch.
>>>>
>>>
>>> Can you be more specific than "It doesn't work fine inside transaction
>>> block", what do you expect to happen and what actually happens?
>>>
>>
>> If we do ALTER SUBSCRIPTION SET PUBLICATION during executing table
>> sync then it forcibly stops concurrently running table sync worker for
>> a table that had been removed from pg_subscription_rel.
>

Hmm, forcibly stopping currently running table sync is not what was
intended, I'll have to look into it. We should not be forcibly stopping
anything except the main apply worker during drop subscription (and we
do that only because we can't drop the remote replication slot otherwise).

> Also, until commit the transaction the worker cannot launch new table
> sync worker due to conflicting tuple lock on pg_subscription_rel.
>

That part is correct, we don't know if the transaction will be rolled
back or not so we can't start workers as the state of the data in the
table in unknown.

--
Petr Jelinek http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2017-06-15 06:48:55 Re: Adding support for Default partition in partitioning
Previous Message Heikki Linnakangas 2017-06-15 06:34:12 Re: [GSOC] [Weekly report 2] Eliminate O(N^2) scaling from rw-conflict tracking in serializable transactions