Re: [HACKERS] Get stuck when dropping a subscription duringsynchronizing table - Mailing list pgsql-hackers

From Masahiko Sawada
Subject Re: [HACKERS] Get stuck when dropping a subscription duringsynchronizing table
Date
Msg-id CAD21AoBkBB+cxnsvWJvrCT=ryLcnma=oGPqefDOQ6E6pT8JLtg@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] Get stuck when dropping a subscription duringsynchronizing table  (Erik Rijkers <er@xs4all.nl>)
Responses Re: [HACKERS] Get stuck when dropping a subscription duringsynchronizing table  (Erik Rijkers <er@xs4all.nl>)
List pgsql-hackers
On Mon, May 8, 2017 at 7:14 PM, Erik Rijkers <er@xs4all.nl> wrote:
> On 2017-05-08 11:27, Masahiko Sawada wrote:
>>
>> Hi,
>>
>> I encountered a situation where DROP SUBSCRIPTION got stuck when
>> initial table sync is in progress. In my environment, I created
>> several tables with some data on publisher. I created subscription on
>> subscriber and drop subscription immediately after that. It doesn't
>> always happen but I often encountered it on my environment.
>>
>> ps -x command shows the following.
>>
>>  96796 ?        Ss     0:00 postgres: masahiko postgres [local] DROP
>> SUBSCRIPTION
>>  96801 ?        Ts     0:00 postgres: bgworker: logical replication
>> worker for subscription 40993    waiting
>>  96805 ?        Ss     0:07 postgres: bgworker: logical replication
>> worker for subscription 40993 sync 16418
>>  96806 ?        Ss     0:01 postgres: wal sender process masahiko [local]
>> idle
>>  96807 ?        Ss     0:00 postgres: bgworker: logical replication
>> worker for subscription 40993 sync 16421
>>  96808 ?        Ss     0:00 postgres: wal sender process masahiko [local]
>> idle
>>
>
> FWIW, running
>
>> 0001-WIP-Fix-off-by-one-around-GetLastImportantRecPtr.patch+
>> 0002-WIP-Possibly-more-robust-snapbuild-approach.patch     +
>> fix-statistics-reporting-in-logical-replication-work.patch
>
>     (on top of 44c528810)

Thanks, which thread are these patches attached on?

>
> I have encountered the same condition as well in the last few days, a few
> times (I think 2 or 3 times).

IIUC there are two issues; one is that the deadlock can happen between
the DROP SUBSCRIPTION and the apply worker process, another one is the
table sync worker can be orphaned if the apply worker exits before
changing status. The latter might relate to another issue reported by
Jeff[1].

[1] https://www.postgresql.org/message-id/CAMkU%3D1xUJKs%3D2etq2K7bmbY51Q7g853HLxJ7qEB2Snog9oRvDw%40mail.gmail.com

Regards,

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



pgsql-hackers by date:

Previous
From: Fabien COELHO
Date:
Subject: Re: [HACKERS] proposal psql \gdesc
Next
From: Petr Jelinek
Date:
Subject: Re: [HACKERS] Get stuck when dropping a subscription duringsynchronizing table