- Notifications
You must be signed in to change notification settings - Fork5.2k
Commita5d4c04
Amit Kapila
Fix self-deadlock during DROP SUBSCRIPTION.
The DROP SUBSCRIPTION command performs several operations: it stops thesubscription workers, removes subscription-related entries from systemcatalogs, and deletes the replication slot on the publisher server.Previously, this command acquired an AccessExclusiveLock onpg_subscription before initiating these steps.However, while holding this lock, the command attempts to connect to thepublisher to remove the replication slot. In cases where the connection ismade to a newly created database on the same server as subscriber, thecache-building process during connection tries to acquire anAccessShareLock on pg_subscription, resulting in a self-deadlock.To resolve this issue, we reduce the lock level on pg_subscription duringDROP SUBSCRIPTION from AccessExclusiveLock to RowExclusiveLock. Earlier,the higher lock level was used to prevent the launcher from starting a newworker during the drop operation, as a restarted worker could becomeorphaned.Now, instead of relying on a strict lock, we acquire an AccessShareLock onthe specific subscription being dropped and re-validate its existenceafter acquiring the lock. If the subscription is no longer valid, theworker exits gracefully. This approach avoids the deadlock while stillensuring that orphan workers are not created.Reported-by: Alexander Lakhin <exclusion@gmail.com>Author: Dilip Kumar <dilipbalaut@gmail.com>Reviewed-by: vignesh C <vignesh21@gmail.com>Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>Backpatch-through: 13Discussion:https://postgr.es/m/18988-7312c868be2d467f@postgresql.org1 parent4483dd9 commita5d4c04
File tree
3 files changed
+42
-3
lines changed- src
- backend
- commands
- replication/logical
- test/subscription/t
3 files changed
+42
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1645 | 1645 | | |
1646 | 1646 | | |
1647 | 1647 | | |
1648 | | - | |
1649 | | - | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
1650 | 1652 | | |
1651 | | - | |
| 1653 | + | |
1652 | 1654 | | |
1653 | 1655 | | |
1654 | 1656 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4682 | 4682 | | |
4683 | 4683 | | |
4684 | 4684 | | |
| 4685 | + | |
| 4686 | + | |
| 4687 | + | |
| 4688 | + | |
| 4689 | + | |
| 4690 | + | |
| 4691 | + | |
4685 | 4692 | | |
4686 | 4693 | | |
4687 | 4694 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
575 | 575 | | |
576 | 576 | | |
577 | 577 | | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
578 | 608 | | |
0 commit comments
Comments
(0)