mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-21 05:43:09 -06:00
Make MaxFederationRetries configurable
This commit is contained in:
parent
5f36c45592
commit
e79f3d6087
|
|
@ -50,7 +50,9 @@ func NewInternalAPI(
|
|||
|
||||
stats := &statistics.Statistics{
|
||||
DB: federationSenderDB,
|
||||
FailuresUntilBlacklist: base.Cfg.Matrix.FederationMaxRetries,
|
||||
}
|
||||
|
||||
queues := queue.NewOutgoingQueues(
|
||||
federationSenderDB, base.Cfg.Matrix.ServerName, federation, rsAPI, stats,
|
||||
&queue.SigningInfo{
|
||||
|
|
|
|||
|
|
@ -11,13 +11,6 @@ import (
|
|||
"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
|
||||
// hosts that we have interacted with. It is basically a threadsafe
|
||||
// wrapper.
|
||||
|
|
@ -25,6 +18,11 @@ type Statistics struct {
|
|||
DB storage.Database
|
||||
servers map[gomatrixserverlib.ServerName]*ServerStatistics
|
||||
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
|
||||
|
|
@ -95,7 +93,7 @@ func (s *ServerStatistics) Failure() bool {
|
|||
failCounter := s.failCounter.Add(1)
|
||||
|
||||
// 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
|
||||
// to back off, which is probably in the region of hours by
|
||||
// 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
|
||||
// requests don't succeed
|
||||
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"`
|
||||
|
||||
// The configuration specific to the media repostitory.
|
||||
|
|
@ -479,6 +484,10 @@ func (config *Dendrite) SetDefaults() {
|
|||
config.Matrix.TrustedIDServers = []string{}
|
||||
}
|
||||
|
||||
if config.Matrix.FederationMaxRetries == 0 {
|
||||
config.Matrix.FederationMaxRetries = 16
|
||||
}
|
||||
|
||||
if config.Media.MaxThumbnailGenerators == 0 {
|
||||
config.Media.MaxThumbnailGenerators = 10
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue