Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
fcfe7a85
Commit
fcfe7a85
authored
6 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Add an awful secondary timeout to fix wedged requests
This is an attempt to mitigate #3842 by adding yet-another-timeout
parent
024be6cf
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/http/matrixfederationclient.py
+11
-0
11 additions, 0 deletions
synapse/http/matrixfederationclient.py
synapse/util/async_helpers.py
+51
-0
51 additions, 0 deletions
synapse/util/async_helpers.py
with
62 additions
and
0 deletions
synapse/http/matrixfederationclient.py
+
11
−
0
View file @
fcfe7a85
...
@@ -42,6 +42,7 @@ from synapse.api.errors import (
...
@@ -42,6 +42,7 @@ from synapse.api.errors import (
)
)
from
synapse.http.endpoint
import
matrix_federation_endpoint
from
synapse.http.endpoint
import
matrix_federation_endpoint
from
synapse.util
import
logcontext
from
synapse.util
import
logcontext
from
synapse.util.async_helpers
import
timeout_no_seriously
from
synapse.util.logcontext
import
make_deferred_yieldable
from
synapse.util.logcontext
import
make_deferred_yieldable
from
synapse.util.metrics
import
Measure
from
synapse.util.metrics
import
Measure
...
@@ -228,6 +229,16 @@ class MatrixFederationHttpClient(object):
...
@@ -228,6 +229,16 @@ class MatrixFederationHttpClient(object):
)
)
request_deferred
.
addTimeout
(
_sec_timeout
,
self
.
hs
.
get_reactor
())
request_deferred
.
addTimeout
(
_sec_timeout
,
self
.
hs
.
get_reactor
())
# Sometimes the timeout above doesn't work, so lets hack yet
# another layer of timeouts in in the vain hope that at some
# point the world made sense and this really really really
# should work.
request_deferred
=
timeout_no_seriously
(
request_deferred
,
timeout
=
_sec_timeout
*
2
,
reactor
=
self
.
hs
.
get_reactor
(),
)
with
Measure
(
self
.
clock
,
"
outbound_request
"
):
with
Measure
(
self
.
clock
,
"
outbound_request
"
):
response
=
yield
make_deferred_yieldable
(
response
=
yield
make_deferred_yieldable
(
request_deferred
,
request_deferred
,
...
...
This diff is collapsed.
Click to expand it.
synapse/util/async_helpers.py
+
51
−
0
View file @
fcfe7a85
...
@@ -438,3 +438,54 @@ def _cancelled_to_timed_out_error(value, timeout):
...
@@ -438,3 +438,54 @@ def _cancelled_to_timed_out_error(value, timeout):
value
.
trap
(
CancelledError
)
value
.
trap
(
CancelledError
)
raise
DeferredTimeoutError
(
timeout
,
"
Deferred
"
)
raise
DeferredTimeoutError
(
timeout
,
"
Deferred
"
)
return
value
return
value
def
timeout_no_seriously
(
deferred
,
timeout
,
reactor
):
"""
The in build twisted deferred addTimeout (and the method above)
completely fail to time things out under some unknown circumstances.
Lets try a different way of timing things out and maybe that will make
things work?!
TODO: Kill this with fire.
"""
new_d
=
defer
.
Deferred
()
timed_out
=
[
False
]
def
time_it_out
():
timed_out
[
0
]
=
True
deferred
.
cancel
()
if
not
new_d
.
called
:
new_d
.
errback
(
DeferredTimeoutError
(
timeout
,
"
Deferred
"
))
delayed_call
=
reactor
.
callLater
(
timeout
,
time_it_out
)
def
convert_cancelled
(
value
):
if
timed_out
[
0
]:
return
_cancelled_to_timed_out_error
(
value
,
timeout
)
return
value
deferred
.
addBoth
(
convert_cancelled
)
def
cancel_timeout
(
result
):
# stop the pending call to cancel the deferred if it's been fired
if
delayed_call
.
active
():
delayed_call
.
cancel
()
return
result
deferred
.
addBoth
(
cancel_timeout
)
def
success_cb
(
val
):
if
not
new_d
.
called
:
new_d
.
callback
(
val
)
def
failure_cb
(
val
):
if
not
new_d
.
called
:
new_d
.
errback
(
val
)
deferred
.
addCallbacks
(
success_cb
,
failure_cb
)
return
new_d
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment