On Wed, May 24, 2017 at 3:14 PM, Petr Jelinek <petr.jeli...@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.
Thank you for the patches! > 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. > The issue reported on this thread seems to be solved with your patch. But because DROP SUBSCRIPTION is only one DDL command that acquires lock on system catalog with AccessExclusiveLock and the logical replication mechanism is complex, I'm concerned that there might be another potential deadlock issue due to acquire lock on system catalog with strong lock level. It might be good idea to do either fine-grained locking or reducing lock level or both. Regards, -- Masahiko Sawada NIPPON TELEGRAPH AND TELEPHONE CORPORATION NTT Open Source Software Center -- Sent via pgsql-hackers mailing list (email@example.com) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers