Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve data consistency and prevent orphaned records in user/tenant management #732

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scur-iolus
Copy link
Contributor

  • I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc.)
  • I have created at least one test case for the changes I have made
  • I have updated the documentation for the changes I have made
  • I have added my changes to the CHANGELOG.md

Pull Request type

  • Bugfix

Makes the transactions atomic when it's relevant to maintain data consistency and integrity. The decorated methods perform multiple database operations. If an error occurs at any step (e.g., a database integrity error, a connection issue, or an unexpected exception), we could end up with a partially updated state where some changes are applied but not all. Wrapping these operations in transaction.atomic ensures that either all changes are applied or none at all. If anything goes wrong, all changes are rolled back, ensuring the database remains in a valid state.

Also, if multiple processes or threads are executing these methods simultaneously, there is a risk of race conditions. Django’s transaction.atomic helps mitigate issues by ensuring that all modifications within the block are treated as a single unit.

Related issue(s)

Copy link

codecov bot commented Jan 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.68%. Comparing base (2b2c385) to head (72547dc).
Report is 130 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #732       +/-   ##
===========================================
+ Coverage   88.36%   99.68%   +11.31%     
===========================================
  Files          18       27        +9     
  Lines         619      939      +320     
  Branches      116      164       +48     
===========================================
+ Hits          547      936      +389     
+ Misses         62        1       -61     
+ Partials       10        2        -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant