-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
ref(hc): Adding helpers for managing transactions #52943
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
Conversation
corps
commented
Jul 15, 2023
- Adds helper such that during a transaction, no executes occur on a differing connection
- Adds helper to collect transaction spans queries run on them, making it possible to write a test assertion about the transactional spans of methods.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #52943 +/- ##
=======================================
Coverage 79.46% 79.46%
=======================================
Files 4936 4936
Lines 207433 207481 +48
Branches 35426 35433 +7
=======================================
+ Hits 164832 164881 +49
Misses 37562 37562
+ Partials 5039 5038 -1
|
with transaction.atomic(using=router.db_for_write(Organization)): | ||
Factories.create_organization() | ||
|
||
with django_test_transaction_water_mark(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the idea that we'll use django_test_transaction_water_mark()
to escape the concurrent transaction detection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
django_test_transaction_water_mark
is used to mark a place when normally, a separate process would be occurring, and thus there would be no other baseline transactions. In a way, it escapes things like transaction.on_commit
and the enforce_no_transaction
and now the mixed transaction detection so that they don't get mixed up with these outer transactions that would not exist in production.
Examples include:
- celery jobs being run synchronously (outboxes)
- initial transactions wrapping tests
- rpc that would be hitting a separate endpoint.
self.alias in open_transactions | ||
), f"Transaction opened for db {open_transactions}, but command running against db {self.alias}" | ||
|
||
return execute(*params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there anything we could wrap this in that would need **kwargs as well?
…using unguarded_write decorators (#53160) With the inclusion of our recent changes to transaction validations in PR #52943 and the inclusion of 'using' in all of our transactions/helpers thanks to PRs #53027 and #53004, we should be able to safely remove the ability to specify a transaction without a using keyword arg. Because this is now mandatory, it should also be safe to remove autorouting, which ended up being incorrect in many testing contexts anyway. This is a resubmission of PR #53080 which was reverted due to broken load-mocks and a single broken getsentry migration test.