-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
feat(action-log): Route recovery through dedicated outbox #121985
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
Draft
cvxluo
wants to merge
2
commits into
master
Choose a base branch
from
cvxluo/route-recovery-through-dedicated-outbox
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ | |
|
|
||
| # Group Action Log — tracks who did what to an issue and how. | ||
| # | ||
| # publish_action() writes a CellOutbox entry; the outbox receiver creates the | ||
| # publish_action() writes an outbox entry; the outbox receiver creates the | ||
| # GroupActionLogEntry on the (eventually separate) grouplog database and kicks | ||
| # off derived-data processing. | ||
| # | ||
|
|
@@ -102,9 +102,10 @@ def publish_action( | |
| # load time so it can be imported from models without creating cycles. | ||
| from django.db import router, transaction | ||
|
|
||
| from sentry import features | ||
| from sentry import features, options | ||
| from sentry.hybridcloud.models.outbox import CellOutbox, outbox_context | ||
| from sentry.hybridcloud.outbox.category import OutboxCategory, OutboxScope | ||
| from sentry.issues.models.groupactionlogoutbox import GroupActionLogOutbox | ||
| from sentry.utils import metrics | ||
|
|
||
| for callback in _publish_callbacks.get(): | ||
|
|
@@ -141,6 +142,13 @@ def publish_action( | |
| if not write_to_db: | ||
| return | ||
|
|
||
| use_dedicated_outbox = options.get("issues.action_log.use_dedicated_outbox") | ||
| outbox_model = GroupActionLogOutbox if use_dedicated_outbox else CellOutbox | ||
| metrics.incr( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wouldn't be unreasonable to include this in issues.action_log. the no-write case could be unset or what we would set, not sure which I prefer. |
||
| "issues.action_log.outbox_write", | ||
| tags={"route": "dedicated" if use_dedicated_outbox else "shared"}, | ||
| ) | ||
|
|
||
| payload: GroupActionLogPayload = { | ||
| "group_id": group_id, | ||
| "project_id": project.id, | ||
|
|
@@ -155,15 +163,15 @@ def publish_action( | |
| if idempotency_key is not None: | ||
| payload["idempotency_key"] = idempotency_key | ||
|
|
||
| outbox = CellOutbox( | ||
| outbox = outbox_model( | ||
| shard_scope=OutboxScope.GROUP_SCOPE, | ||
| shard_identifier=group_id, | ||
| category=OutboxCategory.GROUP_ACTION_LOG_EVENT, | ||
| object_identifier=CellOutbox.next_object_identifier(), | ||
| object_identifier=outbox_model.next_object_identifier(), | ||
| payload=payload, | ||
| ) | ||
| # Flush on commit by default; callers can wrap in outbox_context(flush=False) to defer. | ||
| with outbox_context(transaction.atomic(router.db_for_write(CellOutbox))): | ||
| with outbox_context(transaction.atomic(router.db_for_write(outbox_model))): | ||
| outbox.save() | ||
|
|
||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| import sentry_sdk | ||
|
|
||
| from sentry.hybridcloud.tasks.deliver_from_outbox import ( | ||
| process_outbox_batch, | ||
| schedule_outbox_model, | ||
| ) | ||
| from sentry.issues.models.groupactionlogoutbox import GroupActionLogOutbox | ||
| from sentry.silo.base import SiloMode | ||
| from sentry.tasks.base import instrumented_task | ||
| from sentry.taskworker.namespaces import issues_action_log_tasks | ||
|
|
||
|
|
||
| @instrumented_task( | ||
| name="sentry.issues.action_log.tasks.enqueue_group_action_log_outbox_jobs", | ||
| namespace=issues_action_log_tasks, | ||
| silo_mode=SiloMode.CELL, | ||
| processing_deadline_duration=30, | ||
| ) | ||
| def enqueue_group_action_log_outbox_jobs(concurrency: int | None = None, **kwargs: Any) -> None: | ||
| try: | ||
| schedule_outbox_model( | ||
| silo_mode=SiloMode.CELL, | ||
| outbox_model=GroupActionLogOutbox, | ||
| drain_task=drain_group_action_log_outbox_shards, | ||
| concurrency=concurrency, | ||
| ) | ||
| except Exception: | ||
| sentry_sdk.capture_exception() | ||
| raise | ||
|
|
||
|
|
||
| @instrumented_task( | ||
| name="sentry.issues.action_log.tasks.drain_group_action_log_outbox_shards", | ||
| namespace=issues_action_log_tasks, | ||
| silo_mode=SiloMode.CELL, | ||
| processing_deadline_duration=90, | ||
| ) | ||
| def drain_group_action_log_outbox_shards( | ||
| outbox_identifier_low: int = 0, | ||
| outbox_identifier_hi: int = 0, | ||
| ) -> None: | ||
| try: | ||
| process_outbox_batch( | ||
| outbox_identifier_hi=outbox_identifier_hi, | ||
| outbox_identifier_low=outbox_identifier_low, | ||
| outbox_model=GroupActionLogOutbox, | ||
| ) | ||
| except Exception: | ||
| sentry_sdk.capture_exception() | ||
| raise |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think we wantto use a group-keyed
in_rollout_groupin here. If this is broken and we turn it on for 100% of US, we break lots of things. Better to turn it on for a sampling of groups, and scale up once nothing has failed.