Re: Get stuck when dropping a subscription during synchronizing table
Masahiko Sawada <sawada.mshk@gmail.com>
From: Masahiko Sawada <sawada.mshk@gmail.com>
To: Petr Jelinek <petr.jelinek@2ndquadrant.com>
Cc: Robert Haas <robertmhaas@gmail.com>, Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>, Michael Paquier <michael.paquier@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>, Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Date: 2017-06-01T03:42:28Z
Lists: pgsql-hackers
Attachments
- 0001-Fix-signal-handling-in-logical-workers.patch (application/octet-stream) patch 0001
- 0002-Make-tablesync-worker-exit-when-apply-dies-while-it-.patch (application/octet-stream) patch 0002
- 0003-Receive-invalidation-messages-correctly-in-tablesync.patch (application/octet-stream) patch 0003
- 0004-Wait-for-table-sync-worker-to-finish-when-apply-work.patch (application/octet-stream) patch 0004
On Thu, May 25, 2017 at 4:14 AM, Petr Jelinek <petr.jelinek@2ndquadrant.com> wrote: > Hi, > > I finally had time to properly analyze this, and turns out we've been > all just trying to fix symptoms and the actual problems. > > All the locking works just fine the way it is in master. The issue with > deadlock with apply comes from the wrong handling of the SIGTERM in the > apply (we didn't set InterruptPending). I changed the SIGTERM handler in > patch 0001 just to die which is actually the correct behavior for apply > workers. I also moved the connection cleanup code to the > before_shmem_exit callback (similar to walreceiver) and now that part > works correctly. > > The issue with orphaned sync workers is actually two separate issues. > First, due to thinko we always searched for sync worker in > wait_for_sync_status_change instead of searching for opposite worker as > was the intention (i.e. sync worker should search for apply and apply > should search for sync). Thats fixed by 0002. And second, we didn't > accept any invalidation messages until the whole sync process finished > (because it flattens all the remote transactions in the single one) so > sync worker didn't learn about subscription changes/drop until it has > finished, which I now fixed in 0003. > > There is still outstanding issue that sync worker will keep running > inside the long COPY because the invalidation messages are also not > processed until it finishes but all the original issues reported here > disappear for me with the attached patches applied. > These patches conflict with current HEAD, I attached updated version patches. Also, the issue that sync worker will keep running inside the long COPY can lead the another problem that the user could not create new subscription with some workers due to not enough free logical replication worker slots until the long COPY finishes. Attached 0004 patch is the updated version patch I submitted before. Regards, -- Masahiko Sawada NIPPON TELEGRAPH AND TELEPHONE CORPORATION NTT Open Source Software Center
Commits
-
Fix violations of CatalogTupleInsert/Update/Delete abstraction.
- a571c7f661a7 10.0 cited
-
Use standard interrupt handling in logical replication launcher.
- 2c48f5db64b1 10.0 landed
-
Make tablesync worker exit when apply dies while it was waiting for it
- 3c9bc2157a4f 10.0 cited
-
Use weaker locks when updating pg_subscription_rel
- 521fd4795e3e 10.0 cited