-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
fix(hc): Support split db monolith mode via smarter delegators #53365
fix(hc): Support split db monolith mode via smarter delegators #53365
Conversation
for model, constructor in self._constructors.items(): | ||
# Shared memory reference for the transaction.on_commit | ||
switch = _Switch() | ||
transaction.on_commit(switch, router.db_for_read(model)) |
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.
Actualy, there may be an easier way to make this check, may improve.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #53365 +/- ##
==========================================
- Coverage 79.54% 78.23% -1.32%
==========================================
Files 4940 4917 -23
Lines 208184 208298 +114
Branches 35483 35490 +7
==========================================
- Hits 165600 162960 -2640
- Misses 37545 40154 +2609
- Partials 5039 5184 +145
|
|
||
from sentry.db.postgres.transactions import django_test_transaction_water_mark | ||
from sentry.models import AuditLogEntry, OutboxCategory, OutboxScope, RegionOutbox, UserIP | ||
from sentry.services.hybrid_cloud.log import AuditLogEvent, LogService, UserIpEvent | ||
from sentry.utils import metrics | ||
|
||
|
||
class DatabaseBackedLogService(LogService): |
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.
Awesome that the service implementations themselves get simpler because of this
} | ||
) | ||
|
||
with override_settings(SILO_MODE=SiloMode.CONTROL): |
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.
pytest.mark.parametrize
is sometimes useful for these types of matrices, not sure it'd necessarily make things more clear here though
ServiceInterface, | ||
DelegatedByOpenTransaction( | ||
{ | ||
User: mapping[SiloMode.CONTROL], |
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.
Thinking out loud - if more models are added here, could the silo mode be inferred from the model?
PR reverted: 97c76f2 |
Monolith mode delegators now *also* pick their implementation by attempting to examine any open transactions and selecting for an implementation that would align with the currently open tranaction. This fixes the subtle issue for hybrid cloud services like the log_service, as well as some helper methods on the organization_service, that do not invoke RPC, but rather, *pick different models* locally based on the silo mode. For Monolith mode, this means picking one model that works on one db, even if being invoked inside the transaction of the other db, threatening the transactional atomicity that is desired. (`schedule_signal`, for instance, hopes to leave an outbox behind in the same transaction as invocation). The Sentry Options backend *may* also need this, but unclear. Going to analyze split db tests after this lands and follow up.
Monolith mode delegators now also pick their implementation by attempting to examine any open transactions and selecting for an implementation that would align with the currently open tranaction.
This fixes the subtle issue for hybrid cloud services like the log_service, as well as some helper methods on the organization_service, that do not invoke RPC, but rather, pick different models locally based on the silo mode. For Monolith mode, this means picking one model that works on one db, even if being invoked inside the transaction of the other db, threatening the transactional atomicity that is desired. (
schedule_signal
, for instance, hopes to leave an outbox behind in the same transaction as invocation).The Sentry Options backend may also need this, but unclear. Going to analyze split db tests after this lands and follow up.