-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
fix(hc): Prevent exception from siloed_atomic #52326
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
An exception rises from `router.db_for_write` if the database doesn't exist in the environment, as observed with `SENTRY_USE_SILOS` set to true. Introduce a custom exception type to mark this condition, and catch it when setting the atomic impl. This should be equivalent behavior, as we only care about whether "missing" database is equal to `using` (which a null value won't be).
Related to #51967. @GabeVillalobos Let me know if you agree with my take on the error condition. You should be able to reproduce it by running |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #52326 +/- ##
==========================================
+ Coverage 77.72% 79.32% +1.59%
==========================================
Files 4883 4909 +26
Lines 205442 205768 +326
Branches 35126 35168 +42
==========================================
+ Hits 159681 163221 +3540
+ Misses 40650 37561 -3089
+ Partials 5111 4986 -125
|
Resolve some failures in `tests/getsentry/db/test_router.py` where ValueError is expected. We can make the tests narrower after this change is pushed up to getsentry.
using == router.db_for_write(ControlOutbox) | ||
and SiloMode.get_current_mode() != SiloMode.CONTROL | ||
): | ||
elif using == control_db and SiloMode.get_current_mode() != SiloMode.CONTROL: | ||
raise MismatchedSiloTransactionError( | ||
f"Cannot use transaction.atomic({using}) in Control Mode" |
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.
@RyanSkonnord unsure if these error copies need to be corrected.
f"Cannot use transaction.atomic({using}) in Control Mode" | |
f"Cannot use transaction.atomic({using}) in Region Mode" |
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.
Yes, seems like those should be switched. Or perhaps should say "except in control mode". @GabeVillalobos?
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.
That copy is much better 👍
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.
Great. But it's preexisting, so let's handle it in a separate PR.
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.
An exception rises from
router.db_for_write
if the database doesn't exist in the environment, as observed withSENTRY_USE_SILOS
set to true. Introduce a custom exception type to mark this condition, and catch it when setting the atomic impl. This should be equivalent behavior, as we only care about whether "missing" database is equal tousing
(which a null value won't be).