diff options
author | Richard van der Hoff <richard@matrix.org> | 2018-07-25 10:47:57 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2018-07-25 10:53:23 +0100 |
commit | 07defd5fe6cc6f645195ddf0d679290bb214ca73 (patch) | |
tree | fd2d8d43cf9c87191381c81a89e2738c293edacf /synapse/storage | |
parent | Merge pull request #3597 from matrix-org/erikj/did_forget (diff) | |
download | synapse-07defd5fe6cc6f645195ddf0d679290bb214ca73.tar.xz |
Fix another logcontext leak in _persist_events
We need to run the errback in the sentinel context to avoid losing our own context. Also: add logging to runInteraction to help identify where "Starting db connection from sentinel context" warnings are coming from
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/_base.py | 6 | ||||
-rw-r--r-- | synapse/storage/events.py | 9 |
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 906a405031..ee9e4d4b65 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: |