summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2018-07-25 11:56:00 +0100
committerGitHub <noreply@github.com>2018-07-25 11:56:00 +0100
commitcee1ae1b72bcbf5d173ca2f5eef5e947cc5e69f7 (patch)
treece6789d45874397255e53623f665bb5ad7264d6f /synapse
parentMerge pull request #3607 from matrix-org/rav/fix_persist_events_integrity_error (diff)
parentFix another logcontext leak in _persist_events (diff)
downloadsynapse-cee1ae1b72bcbf5d173ca2f5eef5e947cc5e69f7.tar.xz
Merge pull request #3606 from matrix-org/rav/logcontext_fixes_once_more
Fix another logcontext leak in _persist_events
Diffstat (limited to 'synapse')
-rw-r--r--synapse/storage/_base.py6
-rw-r--r--synapse/storage/events.py9
2 files changed, 10 insertions, 5 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index 1d41d8d445..44f37b4c1e 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -311,6 +311,12 @@ class SQLBaseStore(object):
         after_callbacks = []
         exception_callbacks = []
 
+        if LoggingContext.current_context() == LoggingContext.sentinel:
+            logger.warn(
+                "Starting db txn '%s' from sentinel context",
+                desc,
+            )
+
         try:
             result = yield self.runWithConnection(
                 self._new_transaction,
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index f7c4226ea2..d39796f5ba 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -142,15 +142,14 @@ 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)
+                    except Exception:
+                        with PreserveLoggingContext():
+                            item.deferred.errback()
+                    else:
                         with PreserveLoggingContext():
                             item.deferred.callback(ret)
-                    except Exception:
-                        item.deferred.errback()
             finally:
                 queue = self._event_persist_queues.pop(room_id, None)
                 if queue: