mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-21 13:53:09 -06:00
Make MaxFederationRetries configurable
This commit is contained in:
parent
5f36c45592
commit
e79f3d6087
|
|
@ -49,8 +49,10 @@ func NewInternalAPI(
|
||||||
}
|
}
|
||||||
|
|
||||||
stats := &statistics.Statistics{
|
stats := &statistics.Statistics{
|
||||||
DB: federationSenderDB,
|
DB: federationSenderDB,
|
||||||
|
FailuresUntilBlacklist: base.Cfg.Matrix.FederationMaxRetries,
|
||||||
}
|
}
|
||||||
|
|
||||||
queues := queue.NewOutgoingQueues(
|
queues := queue.NewOutgoingQueues(
|
||||||
federationSenderDB, base.Cfg.Matrix.ServerName, federation, rsAPI, stats,
|
federationSenderDB, base.Cfg.Matrix.ServerName, federation, rsAPI, stats,
|
||||||
&queue.SigningInfo{
|
&queue.SigningInfo{
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,6 @@ import (
|
||||||
"go.uber.org/atomic"
|
"go.uber.org/atomic"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
// How many times should we tolerate consecutive failures before we
|
|
||||||
// just blacklist the host altogether? Bear in mind that the backoff
|
|
||||||
// is exponential, so the max time here to attempt is 2**failures.
|
|
||||||
FailuresUntilBlacklist = 3 // 16 equates to roughly 18 hours.
|
|
||||||
)
|
|
||||||
|
|
||||||
// Statistics contains information about all of the remote federated
|
// Statistics contains information about all of the remote federated
|
||||||
// hosts that we have interacted with. It is basically a threadsafe
|
// hosts that we have interacted with. It is basically a threadsafe
|
||||||
// wrapper.
|
// wrapper.
|
||||||
|
|
@ -25,6 +18,11 @@ type Statistics struct {
|
||||||
DB storage.Database
|
DB storage.Database
|
||||||
servers map[gomatrixserverlib.ServerName]*ServerStatistics
|
servers map[gomatrixserverlib.ServerName]*ServerStatistics
|
||||||
mutex sync.RWMutex
|
mutex sync.RWMutex
|
||||||
|
|
||||||
|
// How many times should we tolerate consecutive failures before we
|
||||||
|
// just blacklist the host altogether? Bear in mind that the backoff
|
||||||
|
// is exponential, so the max time here to attempt is 2**failures.
|
||||||
|
FailuresUntilBlacklist uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
// ForServer returns server statistics for the given server name. If it
|
// ForServer returns server statistics for the given server name. If it
|
||||||
|
|
@ -95,7 +93,7 @@ func (s *ServerStatistics) Failure() bool {
|
||||||
failCounter := s.failCounter.Add(1)
|
failCounter := s.failCounter.Add(1)
|
||||||
|
|
||||||
// Check that we haven't failed more times than is acceptable.
|
// Check that we haven't failed more times than is acceptable.
|
||||||
if failCounter >= FailuresUntilBlacklist {
|
if failCounter >= s.statistics.FailuresUntilBlacklist {
|
||||||
// We've exceeded the maximum amount of times we're willing
|
// We've exceeded the maximum amount of times we're willing
|
||||||
// to back off, which is probably in the region of hours by
|
// to back off, which is probably in the region of hours by
|
||||||
// now. Mark the host as blacklisted and tell the caller to
|
// now. Mark the host as blacklisted and tell the caller to
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,11 @@ type Dendrite struct {
|
||||||
// Perspective keyservers, to use as a backup when direct key fetch
|
// Perspective keyservers, to use as a backup when direct key fetch
|
||||||
// requests don't succeed
|
// requests don't succeed
|
||||||
KeyPerspectives KeyPerspectives `yaml:"key_perspectives"`
|
KeyPerspectives KeyPerspectives `yaml:"key_perspectives"`
|
||||||
|
// Federation failure threshold. How many consecutive failures that we should
|
||||||
|
// tolerate when sending federation requests to a specific server. The backoff
|
||||||
|
// is 2**x seconds, so 1 = 2 seconds, 2 = 4 seconds, 3 = 8 seconds, etc.
|
||||||
|
// The default value is 16 if not specified, which is circa 18 hours.
|
||||||
|
FederationMaxRetries uint32 `yaml:"federation_max_retries"`
|
||||||
} `yaml:"matrix"`
|
} `yaml:"matrix"`
|
||||||
|
|
||||||
// The configuration specific to the media repostitory.
|
// The configuration specific to the media repostitory.
|
||||||
|
|
@ -479,6 +484,10 @@ func (config *Dendrite) SetDefaults() {
|
||||||
config.Matrix.TrustedIDServers = []string{}
|
config.Matrix.TrustedIDServers = []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.Matrix.FederationMaxRetries == 0 {
|
||||||
|
config.Matrix.FederationMaxRetries = 16
|
||||||
|
}
|
||||||
|
|
||||||
if config.Media.MaxThumbnailGenerators == 0 {
|
if config.Media.MaxThumbnailGenerators == 0 {
|
||||||
config.Media.MaxThumbnailGenerators = 10
|
config.Media.MaxThumbnailGenerators = 10
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue