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
928c50b5
Commit
928c50b5
authored
6 years ago
by
Richard van der Hoff
Browse files
Options
Downloads
Patches
Plain Diff
Also jitter the invalid cache period
parent
bc5f6e17
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/http/federation/matrix_federation_agent.py
+11
-9
11 additions, 9 deletions
synapse/http/federation/matrix_federation_agent.py
with
11 additions
and
9 deletions
synapse/http/federation/matrix_federation_agent.py
+
11
−
9
View file @
928c50b5
...
@@ -296,16 +296,18 @@ class MatrixFederationAgent(object):
...
@@ -296,16 +296,18 @@ class MatrixFederationAgent(object):
response
=
yield
make_deferred_yieldable
(
response
=
yield
make_deferred_yieldable
(
self
.
_well_known_agent
.
request
(
b
"
GET
"
,
uri
),
self
.
_well_known_agent
.
request
(
b
"
GET
"
,
uri
),
)
)
body
=
yield
make_deferred_yieldable
(
readBody
(
response
))
if
response
.
code
!=
200
:
raise
Exception
(
"
Non-200 response %s
"
,
response
.
code
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
info
(
"
Connection error fetching %s: %s
"
,
uri_str
,
e
)
logger
.
info
(
"
Error fetching %s: %s
"
,
uri_str
,
e
)
self
.
_well_known_cache
.
set
(
server_name
,
None
,
WELL_KNOWN_INVALID_CACHE_PERIOD
)
defer
.
returnValue
(
None
)
body
=
yield
make_deferred_yieldable
(
readBody
(
response
))
# add some randomness to the TTL to avoid a stampeding herd every hour
# after startup
cache_period
=
WELL_KNOWN_INVALID_CACHE_PERIOD
cache_period
+=
random
.
uniform
(
0
,
WELL_KNOWN_DEFAULT_CACHE_PERIOD_JITTER
)
if
response
.
code
!=
200
:
self
.
_well_known_cache
.
set
(
server_name
,
None
,
cache_period
)
logger
.
info
(
"
Error response %i from %s
"
,
response
.
code
,
uri_str
)
self
.
_well_known_cache
.
set
(
server_name
,
None
,
WELL_KNOWN_INVALID_CACHE_PERIOD
)
defer
.
returnValue
(
None
)
defer
.
returnValue
(
None
)
try
:
try
:
...
@@ -326,8 +328,8 @@ class MatrixFederationAgent(object):
...
@@ -326,8 +328,8 @@ class MatrixFederationAgent(object):
)
)
if
cache_period
is
None
:
if
cache_period
is
None
:
cache_period
=
WELL_KNOWN_DEFAULT_CACHE_PERIOD
cache_period
=
WELL_KNOWN_DEFAULT_CACHE_PERIOD
# add some randomness to the TTL to avoid a stampeding herd every hour
after
# add some randomness to the TTL to avoid a stampeding herd every
24
hour
s
# startup
#
after
startup
cache_period
+=
random
.
uniform
(
0
,
WELL_KNOWN_DEFAULT_CACHE_PERIOD_JITTER
)
cache_period
+=
random
.
uniform
(
0
,
WELL_KNOWN_DEFAULT_CACHE_PERIOD_JITTER
)
else
:
else
:
cache_period
=
min
(
cache_period
,
WELL_KNOWN_MAX_CACHE_PERIOD
)
cache_period
=
min
(
cache_period
,
WELL_KNOWN_MAX_CACHE_PERIOD
)
...
...
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