Re: 024_add_drop_pub.pl might fail due to deadlock
Ajin Cherian <itsajin@gmail.com>
From: Ajin Cherian <itsajin@gmail.com>
To: Alexander Lakhin <exclusion@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-07-14T10:16:17Z
Lists: pgsql-hackers
Attachments
- HEAD-0001-Fix-a-possible-deadlock-during-ALTER-SUBSCRIPTION-.-.patch (application/octet-stream) patch 0001
On Tue, Jul 8, 2025 at 8:41 PM Ajin Cherian <itsajin@gmail.com> wrote: > > Patch with fix attached. > I'll continue investigating whether this issue also affects HEAD. > While debugging if this problem can occur on HEAD, I found out that on head, it is mostly the tablesync worker that drops the origin on HEAD and since the tablesysnc worker does not attempt to update the SubscriptionRel state in that process, there doesn't seem to be the possibility of a deadlock. But there is a rare situation where the tablesync worker could crash or get an error just prior to dropping the origin, then the origin is dropped in the apply worker (this is explained in the comments in process_syncing_tables_for_sync()). If the origin has to be dropped in the apply worker, then the same deadlock can happen in HEAD code as well. I was able to simulate this by using an injection point to create an error on the tablesync worker and then the similar deadlock happens on HEAD as well. Attaching a patch for fixing this on HEAD as well. regards, Ajin Cherian Fujitsu Australia
Commits
-
Fix a deadlock during ALTER SUBSCRIPTION ... DROP PUBLICATION.
- 2ab2d6f97058 19 (unreleased) landed
- d9f01a287ab1 18.0 landed
- 434d2d147b58 15.14 landed
- 41fb3f51cb74 14.19 landed
- 8c298324a4f3 17.6 landed
- adfd8021911a 16.10 landed