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

Fix dropped logcontexts during high outbound traffic. #5277

Merged
merged 1 commit into from
May 29, 2019
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/5277.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix dropped logcontexts during high outbound traffic.
20 changes: 13 additions & 7 deletions synapse/app/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,21 @@ def __init__(self, resolver, max_dns_requests_in_flight):

def resolveHostName(self, resolutionReceiver, hostName, portNumber=0,
addressTypes=None, transportSemantics='TCP'):
# Note this is happening deep within the reactor, so we don't need to
# worry about log contexts.

# We need this function to return `resolutionReceiver` so we do all the
# actual logic involving deferreds in a separate function.
self._resolve(
resolutionReceiver, hostName, portNumber,
addressTypes, transportSemantics,
)

# even though this is happening within the depths of twisted, we need to drop
# our logcontext before starting _resolve, otherwise: (a) _resolve will drop
# the logcontext if it returns an incomplete deferred; (b) _resolve will
# call the resolutionReceiver *with* a logcontext, which it won't be expecting.
with PreserveLoggingContext():
self._resolve(
resolutionReceiver,
hostName,
portNumber,
addressTypes,
transportSemantics,
)

return resolutionReceiver

Expand Down