Browse Source

fix(sourcemaps): Add transaction to delete (#46310)

Riccardo Busetti 1 year ago
parent
commit
4447c0a355
1 changed files with 5 additions and 4 deletions
  1. 5 4
      src/sentry/tasks/assemble.py

+ 5 - 4
src/sentry/tasks/assemble.py

@@ -3,7 +3,7 @@ import logging
 from os import path
 from typing import List, Optional, Tuple
 
-from django.db import IntegrityError, router
+from django.db import IntegrityError, router, transaction
 from django.db.models import Q
 from django.utils import timezone
 from symbolic import SymbolicError, normalize_debug_id
@@ -284,9 +284,10 @@ def _extract_debug_ids_from_manifest(
 
 
 def _remove_duplicate_artifact_bundles(except_id: int, bundle_id: str):
-    # Even though we delete via a QuerySet the associated file is also deleted, because django will still
-    # fire the on_delete signal.
-    ArtifactBundle.objects.filter(~Q(id=except_id), bundle_id=bundle_id).delete()
+    with transaction.atomic():
+        # Even though we delete via a QuerySet the associated file is also deleted, because django will still
+        # fire the on_delete signal.
+        ArtifactBundle.objects.filter(~Q(id=except_id), bundle_id=bundle_id).delete()
 
 
 def _create_artifact_bundle(