Просмотр исходного кода

ref(proj-config): Wrap scheduling in a sentry span (#45631)

Updating a lot of organizations or projects in a single database
transaction causes the `on_commit` list to grow considerably and may
cause memory leaks. It may be very hard to identify these cases.

In an attempt to make these simpler, the `on_commit` call is surrounded
by a sentry span to make it easier to identify on Sentry.
Iker Barriocanal 2 лет назад
Родитель
Сommit
14db27e02a
1 измененных файлов с 14 добавлено и 8 удалено
  1. 14 8
      src/sentry/tasks/relay.py

+ 14 - 8
src/sentry/tasks/relay.py

@@ -270,15 +270,21 @@ def schedule_invalidate_project_config(
         slight delay to increase the likelihood of deduplicating invalidations but you can
         tweak this, like e.g. the :func:`invalidate_all` task does.
     """
-    transaction.on_commit(
-        lambda: _schedule_invalidate_project_config(
-            trigger=trigger,
-            organization_id=organization_id,
-            project_id=project_id,
-            public_key=public_key,
-            countdown=countdown,
+    with sentry_sdk.start_span(
+        op="relay.projectconfig_cache.invalidation.schedule_after_db_transaction",
+    ):
+        # XXX(iker): updating a lot of organizations or projects in a single
+        # database transaction causes the `on_commit` list to grow considerably
+        # and may cause memory leaks.
+        transaction.on_commit(
+            lambda: _schedule_invalidate_project_config(
+                trigger=trigger,
+                organization_id=organization_id,
+                project_id=project_id,
+                public_key=public_key,
+                countdown=countdown,
+            )
         )
-    )
 
 
 def _schedule_invalidate_project_config(