Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix another logcontext leak in _persist_events #3606

Merged
merged 1 commit into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/3606.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix some random logcontext leaks.
6 changes: 6 additions & 0 deletions synapse/storage/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ def runInteraction(self, desc, func, *args, **kwargs):
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,
Expand Down
9 changes: 4 additions & 5 deletions synapse/storage/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,14 @@ def handle_queue_loop():
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:
Expand Down