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

Commit

Permalink
Fix dropped logcontexts during high outbound traffic.
Browse files Browse the repository at this point in the history
Fixes #5271.
  • Loading branch information
richvdh committed May 28, 2019
1 parent a97d4e2 commit eeceb7a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
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

0 comments on commit eeceb7a

Please sign in to comment.