summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2022-02-22 13:33:22 +0000
committerGitHub <noreply@github.com>2022-02-22 13:33:22 +0000
commit81364db49b7778021edcd5912555dd3e1583c1b8 (patch)
treefa3bed2aeae73c18a7bb78fed15eac6aa27ea686
parentFix slow performance of `/logout` in some cases where refresh tokens are in u... (diff)
downloadsynapse-81364db49b7778021edcd5912555dd3e1583c1b8.tar.xz
Run `_handle_queued_pdus` as a background process (#12041)
... to ensure it gets a proper log context, mostly.
-rw-r--r--changelog.d/12041.misc1
-rw-r--r--synapse/handlers/federation.py6
2 files changed, 5 insertions, 2 deletions
diff --git a/changelog.d/12041.misc b/changelog.d/12041.misc
new file mode 100644
index 0000000000..e56dc093de
--- /dev/null
+++ b/changelog.d/12041.misc
@@ -0,0 +1 @@
+After joining a room, create a dedicated logcontext to process the queued events.
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py
index c8356f233d..e9ac920bcc 100644
--- a/synapse/handlers/federation.py
+++ b/synapse/handlers/federation.py
@@ -49,8 +49,8 @@ from synapse.logging.context import (
     make_deferred_yieldable,
     nested_logging_context,
     preserve_fn,
-    run_in_background,
 )
+from synapse.metrics.background_process_metrics import run_as_background_process
 from synapse.replication.http.federation import (
     ReplicationCleanRoomRestServlet,
     ReplicationStoreRoomOnOutlierMembershipRestServlet,
@@ -559,7 +559,9 @@ class FederationHandler:
             # lots of requests for missing prev_events which we do actually
             # have. Hence we fire off the background task, but don't wait for it.
 
-            run_in_background(self._handle_queued_pdus, room_queue)
+            run_as_background_process(
+                "handle_queued_pdus", self._handle_queued_pdus, room_queue
+            )
 
     async def do_knock(
         self,