summary refs log tree commit diff
path: root/synapse/storage/events.py
diff options
context:
space:
mode:
authorRichard van der Hoff <github@rvanderhoff.org.uk>2018-01-16 14:09:13 +0000
committerGitHub <noreply@github.com>2018-01-16 14:09:13 +0000
commitf5f89fda218e67193702bf15f6c89315926ef499 (patch)
tree6489fce97c59f681bf2921d1b4b9d600fde81153 /synapse/storage/events.py
parentMerge pull request #2787 from matrix-org/rav/worker_event_counts (diff)
parentFix a logcontext leak in persist_events (diff)
downloadsynapse-f5f89fda218e67193702bf15f6c89315926ef499.tar.xz
Merge pull request #2790 from matrix-org/rav/preserve_event_logcontext_leak
Fix a logcontext leak in persist_events
Diffstat (limited to 'synapse/storage/events.py')
-rw-r--r--synapse/storage/events.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index d08f7571d7..ad1d782705 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -146,6 +146,9 @@ class _EventPeristenceQueue(object):
             try:
                 queue = self._get_drainining_queue(room_id)
                 for item in queue:
+                    # handle_queue_loop runs in the sentinel logcontext, so
+                    # there is no need to preserve_fn when running the
+                    # callbacks on the deferred.
                     try:
                         ret = yield per_item_callback(item)
                         item.deferred.callback(ret)
@@ -157,7 +160,11 @@ class _EventPeristenceQueue(object):
                     self._event_persist_queues[room_id] = queue
                 self._currently_persisting_rooms.discard(room_id)
 
-        preserve_fn(handle_queue_loop)()
+        # set handle_queue_loop off on the background. We don't want to
+        # attribute work done in it to the current request, so we drop the
+        # logcontext altogether.
+        with PreserveLoggingContext():
+            handle_queue_loop()
 
     def _get_drainining_queue(self, room_id):
         queue = self._event_persist_queues.setdefault(room_id, deque())