Commit 930c33b
committed
Fix race condition in duplicate InstallPlan prevention
Move the listInstallPlans() call to after the muInstallPlan lock is
acquired in ensureInstallPlan(). Previously, the check for existing
install plans happened before acquiring the lock, which meant that
worker 2 could check for install plans before worker 1 had a chance
to create one, even with the lock in place.
This fixes the race condition by ensuring that the sequence is:
1. Worker 1 acquires lock
2. Worker 1 checks for existing install plans
3. Worker 1 creates new install plan (if needed)
4. Worker 1 releases lock
5. Worker 2 acquires lock
6. Worker 2 checks for existing install plans (now sees worker 1's)
7. Worker 2 reuses existing install plan
8. Worker 2 releases lock
Without this fix, both workers could see no existing install plans
before either acquired the lock, leading to duplicate install plans
being created for the same subscription.1 parent 971d680 commit 930c33b
1 file changed
+8
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1654 | 1654 | | |
1655 | 1655 | | |
1656 | 1656 | | |
1657 | | - | |
1658 | | - | |
1659 | | - | |
1660 | | - | |
1661 | | - | |
1662 | | - | |
1663 | 1657 | | |
1664 | 1658 | | |
1665 | 1659 | | |
| |||
1680 | 1674 | | |
1681 | 1675 | | |
1682 | 1676 | | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
1683 | 1685 | | |
1684 | 1686 | | |
1685 | 1687 | | |
| |||
0 commit comments