Re: Get stuck when dropping a subscription during synchronizing table

Erik Rijkers <er@xs4all.nl>

From: Erik Rijkers <er@xs4all.nl>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>, pgsql-hackers-owner@postgresql.org
Date: 2017-05-08T10:14:25Z
Lists: pgsql-hackers
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)

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

Erik Rijkers


Commits

  1. Fix violations of CatalogTupleInsert/Update/Delete abstraction.

  2. Use standard interrupt handling in logical replication launcher.

  3. Make tablesync worker exit when apply dies while it was waiting for it

  4. Use weaker locks when updating pg_subscription_rel