Skip to content

feat(issues): add merge task killswitch#118611

Merged
cvxluo merged 1 commit into
masterfrom
cvxluo/add-merge-task-killswitch
Jun 27, 2026
Merged

feat(issues): add merge task killswitch#118611
cvxluo merged 1 commit into
masterfrom
cvxluo/add-merge-task-killswitch

Conversation

@cvxluo

@cvxluo cvxluo commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

For inc-2274

@cvxluo cvxluo requested review from a team as code owners June 26, 2026 23:44
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 26, 2026
Comment thread src/sentry/tasks/merge.py
Comment on lines +82 to +84
if eventstream_state:
eventstream.backend.end_merge(eventstream_state)
return False

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Calling end_merge when the merge killswitch is activated can leave groups in a PENDING_MERGE state while prematurely notifying Snuba that the merge is complete.
Severity: HIGH

Suggested Fix

When the killswitch is activated, the end_merge function should not be called with the original, complete list of previous_group_ids. Instead, the system should either revert the PENDING_MERGE status for any unprocessed groups or call end_merge only with the IDs of groups that were successfully merged before the interruption.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/sentry/tasks/merge.py#L82-L84

Potential issue: The new killswitch logic can cause a state inconsistency between the
primary database and Snuba. If the killswitch is activated during a recursive merge
operation, `end_merge` is called immediately. This function is invoked with the original
`eventstream_state`, which includes all group IDs from the start of the merge. However,
if only a subset of groups has been processed, the remaining groups will be left in a
`PENDING_MERGE` state in the database. Snuba receives the `end_merge` signal for all
groups, leading it to believe the entire operation is finished. This discrepancy causes
Snuba's event routing to be incorrect for the unprocessed groups.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine, them staying in pending_merge is ok they will have to just be cleaned up manually when after a killswitch which is acceptable

@cvxluo cvxluo merged commit 64451ea into master Jun 27, 2026
90 checks passed
@cvxluo cvxluo deleted the cvxluo/add-merge-task-killswitch branch June 27, 2026 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants