Repository navigation
fix: prevent deadlock when deleting user with orphan organisations - #8837
srijantrpth wants to merge 3 commits into
Conversation
|
@srijantrpth is attempting to deploy a commit to the Flagsmith Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 Walkthrough
Merge Risk: 🟡 Moderate · up to
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8837 +/- ##
==========================================
- Coverage 98.88% 97.98% -0.90%
==========================================
Files 1683 1683
Lines 70275 70273 -2
==========================================
- Hits 69489 68860 -629
- Misses 786 1413 +627 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
38ce1a3c-73db-439d-b6bb-22c85be1cc41
📒 Files selected for processing: 2
api/e2etests/e2e_seed_data.pyapi/users/models.py
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
4fc5ac09-0c24-48c0-a351-4b6b8b27c137
📒 Files selected for processing: 1
api/projects/models.py
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
432b261 to
d2f91f9
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
29a199fc-2b05-4e6a-816c-25d5e6ece5b6
📒 Files selected for processing: 1
api/tests/unit/projects/test_unit_projects_views.py
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
054b5bb to
31f5e76
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
d6f5d131-d1e6-4603-ab6e-78de8459c03d
📒 Files selected for processing: 4
api/e2etests/e2e_seed_data.pyapi/projects/models.pyapi/tests/unit/projects/test_unit_projects_views.pyapi/users/models.py
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
293ecab to
1baf14e
Compare
for more information, see https://pre-commit.ci
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Closes #8775
This PR fixes a Postgres deadlock that occurs when deleting a user who is the sole member of an organisation.
Previously,
FFAdminUser.delete()executed in two separate transactions, causing a race condition where the task processor's background cascade-delete tasks would attempt to lock the same rows in reverse order. This PR wraps bothFFAdminUser.delete()and the e2e teardown functiondelete_user_and_its_organisations()intransaction.atomic()context managers to ensure the deletion commits fully before background tasks are queued.How did you test this code?
make test opts="tests/unit/users/") to ensure user deletion logic still passes.transaction.atomic()syntax and logic successfully bypasses the race condition documented in the issue.