Re: Get stuck when dropping a subscription during synchronizing table

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Erik Rijkers <er(at)xs4all(dot)nl>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, pgsql-hackers-owner(at)postgresql(dot)org
Subject: Re: Get stuck when dropping a subscription during synchronizing table
Date: 2017-05-08 11:13:15
Message-ID: CAD21AoBkBB+cxnsvWJvrCT=ryLcnma=oGPqefDOQ6E6pT8JLtg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, May 8, 2017 at 7:14 PM, Erik Rijkers <er(at)xs4all(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Petr Jelinek 2017-05-08 11:42:32 Re: Get stuck when dropping a subscription during synchronizing table
Previous Message Fabien COELHO 2017-05-08 10:59:01 Re: proposal psql \gdesc