Skip to content

feat(deletions): Task for deleting nodestore events #96795

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
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

armenzg
Copy link
Member

@armenzg armenzg commented Jul 30, 2025

Groups with millions of events fail to be deleted because the nodestore deletions fail.

This creates a new task to handle the deletions in parallel.

An option is to be added to control switching to this new task.

Fixes ID-821

@armenzg armenzg self-assigned this Jul 30, 2025
Copy link

linear bot commented Jul 30, 2025

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 30, 2025
Copy link

codecov bot commented Jul 30, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
26822 1 26821 600
View the top 1 failed test(s) by shortest run time
tests.sentry.deletions.test_group.DeleteGroupTest::test_simple_multiple_groups_parallel
Stack Traces | 5.12s run time
#x1B[1m#x1B[.../sentry/deletions/test_group.py#x1B[0m:119: in test_simple_multiple_groups_parallel
    group_ids = [self.event.group.id, self.event_id2.group.id]
#x1B[1m#x1B[31mE   AttributeError: 'str' object has no attribute 'group'#x1B[0m

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@armenzg
Copy link
Member Author

armenzg commented Jul 31, 2025

bugbot run

@@ -114,6 +114,24 @@ def test_simple_multiple_groups(self) -> None:
assert Group.objects.filter(id=self.keep_event.group_id).exists()
assert nodestore.backend.get(self.keep_node_id)

def test_simple_multiple_groups_parallel(self) -> None:
with self.options({"deletions.nodestore.parallelization-task-enabled": True}):
group_ids = [self.event.group.id, self.event_id2.group.id]
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Event ID String Access Fails

Accessing self.event_id2.group.id causes an AttributeError because self.event_id2 is an event ID string, not an Event object. This is due to self.event_id2 being assigned self.store_event(...).event_id in the setUp method, which extracts only the string ID.

Locations (1)
Fix in Cursor Fix in Web

)

assert not Group.objects.filter(id__in=group_ids).exists()
assert not nodestore.backend.get_multi([self.event_node_id, self.node_id2])
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Undefined Node ID Causes Test Failure

The newly added test test_simple_multiple_groups_parallel references self.event_node_id, which is not defined in the test setup. This causes a NameError at runtime. It should likely be self.node_id, which is the correct node ID for self.event.

Locations (1)
Fix in Cursor Fix in Web


def _delete_events_from_nodestore(events: Sequence[Event], extra: dict[str, Any]) -> None:
node_ids = [Event.generate_node_id(event.project_id, event.event_id) for event in events]
nodestore.backend.delete_multi(node_ids)
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Issue Platform Events Deletion Fails

The new parallel nodestore deletion task, specifically the _delete_events_from_nodestore function, incorrectly generates node IDs for Issue Platform events. It consistently uses event.event_id, whereas for Dataset.IssuePlatform events, the node ID should be derived from event._snuba_data["occurrence_id"]. This discrepancy prevents Issue Platform events from being properly deleted from nodestore.

Locations (1)
Fix in Cursor Fix in Web

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.

1 participant