2020-07-22 16:01:29 +00:00
|
|
|
package statistics
|
Improve federation sender performance, implement backoff and blacklisting, fix up invites a bit (#1007)
* Improve federation sender performance and behaviour, add backoff
* Tweaks
* Tweaks
* Tweaks
* Take copies of events before passing to destination queues
* Don't accidentally drop queued messages
* Don't take copies again
* Tidy up a bit
* Break out statistics (tracked component-wide), report success and failures from Perform actions
* Fix comment, use atomic add
* Improve logic a bit, don't block on wakeup, move idle check
* Don't retry sucessful invites, don't dispatch sendEvent, sendInvite etc
* Dedupe destinations, fix other bug hopefully
* Dispatch sends again
* Federation sender to ignore invites that are destined locally
* Loopback invite events
* Remodel a bit with channels
* Linter
* Only loopback invite event if we know the room
* We should tell other resident servers about the invite if we know about the room
* Correct invite signing
* Fix invite loopback
* Check HTTP response codes, push new invites to front of queue
* Review comments
2020-05-07 11:42:06 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"math"
|
2022-10-19 10:03:16 +00:00
|
|
|
"math/rand"
|
Improve federation sender performance, implement backoff and blacklisting, fix up invites a bit (#1007)
* Improve federation sender performance and behaviour, add backoff
* Tweaks
* Tweaks
* Tweaks
* Take copies of events before passing to destination queues
* Don't accidentally drop queued messages
* Don't take copies again
* Tidy up a bit
* Break out statistics (tracked component-wide), report success and failures from Perform actions
* Fix comment, use atomic add
* Improve logic a bit, don't block on wakeup, move idle check
* Don't retry sucessful invites, don't dispatch sendEvent, sendInvite etc
* Dedupe destinations, fix other bug hopefully
* Dispatch sends again
* Federation sender to ignore invites that are destined locally
* Loopback invite events
* Remodel a bit with channels
* Linter
* Only loopback invite event if we know the room
* We should tell other resident servers about the invite if we know about the room
* Correct invite signing
* Fix invite loopback
* Check HTTP response codes, push new invites to front of queue
* Review comments
2020-05-07 11:42:06 +00:00
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
2020-07-22 16:01:29 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
Improve federation sender performance, implement backoff and blacklisting, fix up invites a bit (#1007)
* Improve federation sender performance and behaviour, add backoff
* Tweaks
* Tweaks
* Tweaks
* Take copies of events before passing to destination queues
* Don't accidentally drop queued messages
* Don't take copies again
* Tidy up a bit
* Break out statistics (tracked component-wide), report success and failures from Perform actions
* Fix comment, use atomic add
* Improve logic a bit, don't block on wakeup, move idle check
* Don't retry sucessful invites, don't dispatch sendEvent, sendInvite etc
* Dedupe destinations, fix other bug hopefully
* Dispatch sends again
* Federation sender to ignore invites that are destined locally
* Loopback invite events
* Remodel a bit with channels
* Linter
* Only loopback invite event if we know the room
* We should tell other resident servers about the invite if we know about the room
* Correct invite signing
* Fix invite loopback
* Check HTTP response codes, push new invites to front of queue
* Review comments
2020-05-07 11:42:06 +00:00
|
|
|
"go.uber.org/atomic"
|
2022-08-23 14:54:42 +00:00
|
|
|
|
|
|
|
"github.com/matrix-org/dendrite/federationapi/storage"
|
Improve federation sender performance, implement backoff and blacklisting, fix up invites a bit (#1007)
* Improve federation sender performance and behaviour, add backoff
* Tweaks
* Tweaks
* Tweaks
* Take copies of events before passing to destination queues
* Don't accidentally drop queued messages
* Don't take copies again
* Tidy up a bit
* Break out statistics (tracked component-wide), report success and failures from Perform actions
* Fix comment, use atomic add
* Improve logic a bit, don't block on wakeup, move idle check
* Don't retry sucessful invites, don't dispatch sendEvent, sendInvite etc
* Dedupe destinations, fix other bug hopefully
* Dispatch sends again
* Federation sender to ignore invites that are destined locally
* Loopback invite events
* Remodel a bit with channels
* Linter
* Only loopback invite event if we know the room
* We should tell other resident servers about the invite if we know about the room
* Correct invite signing
* Fix invite loopback
* Check HTTP response codes, push new invites to front of queue
* Review comments
2020-05-07 11:42:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Statistics contains information about all of the remote federated
|
|
|
|
// hosts that we have interacted with. It is basically a threadsafe
|
|
|
|
// wrapper.
|
|
|
|
type Statistics struct {
|
2020-07-22 16:01:29 +00:00
|
|
|
DB storage.Database
|
Improve federation sender performance, implement backoff and blacklisting, fix up invites a bit (#1007)
* Improve federation sender performance and behaviour, add backoff
* Tweaks
* Tweaks
* Tweaks
* Take copies of events before passing to destination queues
* Don't accidentally drop queued messages
* Don't take copies again
* Tidy up a bit
* Break out statistics (tracked component-wide), report success and failures from Perform actions
* Fix comment, use atomic add
* Improve logic a bit, don't block on wakeup, move idle check
* Don't retry sucessful invites, don't dispatch sendEvent, sendInvite etc
* Dedupe destinations, fix other bug hopefully
* Dispatch sends again
* Federation sender to ignore invites that are destined locally
* Loopback invite events
* Remodel a bit with channels
* Linter
* Only loopback invite event if we know the room
* We should tell other resident servers about the invite if we know about the room
* Correct invite signing
* Fix invite loopback
* Check HTTP response codes, push new invites to front of queue
* Review comments
2020-05-07 11:42:06 +00:00
|
|
|
servers map[gomatrixserverlib.ServerName]*ServerStatistics
|
|
|
|
mutex sync.RWMutex
|
2020-07-22 16:01:29 +00:00
|
|
|
|
2022-10-19 10:03:16 +00:00
|
|
|
backoffTimers map[gomatrixserverlib.ServerName]*time.Timer
|
|
|
|
backoffMutex sync.RWMutex
|
|
|
|
|
2020-07-22 16:01:29 +00:00
|
|
|
// How many times should we tolerate consecutive failures before we
|
|
|
|
// just blacklist the host altogether? The backoff is exponential,
|
|
|
|
// so the max time here to attempt is 2**failures seconds.
|
|
|
|
FailuresUntilBlacklist uint32
|
Improve federation sender performance, implement backoff and blacklisting, fix up invites a bit (#1007)
* Improve federation sender performance and behaviour, add backoff
* Tweaks
* Tweaks
* Tweaks
* Take copies of events before passing to destination queues
* Don't accidentally drop queued messages
* Don't take copies again
* Tidy up a bit
* Break out statistics (tracked component-wide), report success and failures from Perform actions
* Fix comment, use atomic add
* Improve logic a bit, don't block on wakeup, move idle check
* Don't retry sucessful invites, don't dispatch sendEvent, sendInvite etc
* Dedupe destinations, fix other bug hopefully
* Dispatch sends again
* Federation sender to ignore invites that are destined locally
* Loopback invite events
* Remodel a bit with channels
* Linter
* Only loopback invite event if we know the room
* We should tell other resident servers about the invite if we know about the room
* Correct invite signing
* Fix invite loopback
* Check HTTP response codes, push new invites to front of queue
* Review comments
2020-05-07 11:42:06 +00:00
|
|
|
}
|
|
|
|
|
2022-10-19 10:03:16 +00:00
|
|
|
func NewStatistics(db storage.Database, failuresUntilBlacklist uint32) Statistics {
|
|
|
|
return Statistics{
|
|
|
|
DB: db,
|
|
|
|
FailuresUntilBlacklist: failuresUntilBlacklist,
|
|
|
|
backoffTimers: make(map[gomatrixserverlib.ServerName]*time.Timer),
|
2023-01-12 16:22:53 +00:00
|
|
|
servers: make(map[gomatrixserverlib.ServerName]*ServerStatistics),
|
2022-10-19 10:03:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Improve federation sender performance, implement backoff and blacklisting, fix up invites a bit (#1007)
* Improve federation sender performance and behaviour, add backoff
* Tweaks
* Tweaks
* Tweaks
* Take copies of events before passing to destination queues
* Don't accidentally drop queued messages
* Don't take copies again
* Tidy up a bit
* Break out statistics (tracked component-wide), report success and failures from Perform actions
* Fix comment, use atomic add
* Improve logic a bit, don't block on wakeup, move idle check
* Don't retry sucessful invites, don't dispatch sendEvent, sendInvite etc
* Dedupe destinations, fix other bug hopefully
* Dispatch sends again
* Federation sender to ignore invites that are destined locally
* Loopback invite events
* Remodel a bit with channels
* Linter
* Only loopback invite event if we know the room
* We should tell other resident servers about the invite if we know about the room
* Correct invite signing
* Fix invite loopback
* Check HTTP response codes, push new invites to front of queue
* Review comments
2020-05-07 11:42:06 +00:00
|
|
|
// ForServer returns server statistics for the given server name. If it
|
|
|
|
// does not exist, it will create empty statistics and return those.
|
|
|
|
func (s *Statistics) ForServer(serverName gomatrixserverlib.ServerName) *ServerStatistics {
|
|
|
|
// Look up if we have statistics for this server already.
|
|
|
|
s.mutex.RLock()
|
|
|
|
server, found := s.servers[serverName]
|
|
|
|
s.mutex.RUnlock()
|
|
|
|
// If we don't, then make one.
|
|
|
|
if !found {
|
|
|
|
s.mutex.Lock()
|
2020-07-22 16:01:29 +00:00
|
|
|
server = &ServerStatistics{
|
|
|
|
statistics: s,
|
|
|
|
serverName: serverName,
|
|
|
|
}
|
Improve federation sender performance, implement backoff and blacklisting, fix up invites a bit (#1007)
* Improve federation sender performance and behaviour, add backoff
* Tweaks
* Tweaks
* Tweaks
* Take copies of events before passing to destination queues
* Don't accidentally drop queued messages
* Don't take copies again
* Tidy up a bit
* Break out statistics (tracked component-wide), report success and failures from Perform actions
* Fix comment, use atomic add
* Improve logic a bit, don't block on wakeup, move idle check
* Don't retry sucessful invites, don't dispatch sendEvent, sendInvite etc
* Dedupe destinations, fix other bug hopefully
* Dispatch sends again
* Federation sender to ignore invites that are destined locally
* Loopback invite events
* Remodel a bit with channels
* Linter
* Only loopback invite event if we know the room
* We should tell other resident servers about the invite if we know about the room
* Correct invite signing
* Fix invite loopback
* Check HTTP response codes, push new invites to front of queue
* Review comments
2020-05-07 11:42:06 +00:00
|
|
|
s.servers[serverName] = server
|
|
|
|
s.mutex.Unlock()
|
2020-07-22 16:01:29 +00:00
|
|
|
blacklisted, err := s.DB.IsServerBlacklisted(serverName)
|
|
|
|
if err != nil {
|
|
|
|
logrus.WithError(err).Errorf("Failed to get blacklist entry %q", serverName)
|
|
|
|
} else {
|
|
|
|
server.blacklisted.Store(blacklisted)
|
|
|
|
}
|
Improve federation sender performance, implement backoff and blacklisting, fix up invites a bit (#1007)
* Improve federation sender performance and behaviour, add backoff
* Tweaks
* Tweaks
* Tweaks
* Take copies of events before passing to destination queues
* Don't accidentally drop queued messages
* Don't take copies again
* Tidy up a bit
* Break out statistics (tracked component-wide), report success and failures from Perform actions
* Fix comment, use atomic add
* Improve logic a bit, don't block on wakeup, move idle check
* Don't retry sucessful invites, don't dispatch sendEvent, sendInvite etc
* Dedupe destinations, fix other bug hopefully
* Dispatch sends again
* Federation sender to ignore invites that are destined locally
* Loopback invite events
* Remodel a bit with channels
* Linter
* Only loopback invite event if we know the room
* We should tell other resident servers about the invite if we know about the room
* Correct invite signing
* Fix invite loopback
* Check HTTP response codes, push new invites to front of queue
* Review comments
2020-05-07 11:42:06 +00:00
|
|
|
}
|
|
|
|
return server
|
|
|
|
}
|
|
|
|
|
|
|
|
// ServerStatistics contains information about our interactions with a
|
|
|
|
// remote federated host, e.g. how many times we were successful, how
|
|
|
|
// many times we failed etc. It also manages the backoff time and black-
|
|
|
|
// listing a remote host if it remains uncooperative.
|
|
|
|
type ServerStatistics struct {
|
2022-10-19 10:03:16 +00:00
|
|
|
statistics *Statistics //
|
|
|
|
serverName gomatrixserverlib.ServerName //
|
|
|
|
blacklisted atomic.Bool // is the node blacklisted
|
|
|
|
backoffStarted atomic.Bool // is the backoff started
|
|
|
|
backoffUntil atomic.Value // time.Time until this backoff interval ends
|
|
|
|
backoffCount atomic.Uint32 // number of times BackoffDuration has been called
|
|
|
|
successCounter atomic.Uint32 // how many times have we succeeded?
|
|
|
|
backoffNotifier func() // notifies destination queue when backoff completes
|
|
|
|
notifierMutex sync.Mutex
|
Improve federation sender performance, implement backoff and blacklisting, fix up invites a bit (#1007)
* Improve federation sender performance and behaviour, add backoff
* Tweaks
* Tweaks
* Tweaks
* Take copies of events before passing to destination queues
* Don't accidentally drop queued messages
* Don't take copies again
* Tidy up a bit
* Break out statistics (tracked component-wide), report success and failures from Perform actions
* Fix comment, use atomic add
* Improve logic a bit, don't block on wakeup, move idle check
* Don't retry sucessful invites, don't dispatch sendEvent, sendInvite etc
* Dedupe destinations, fix other bug hopefully
* Dispatch sends again
* Federation sender to ignore invites that are destined locally
* Loopback invite events
* Remodel a bit with channels
* Linter
* Only loopback invite event if we know the room
* We should tell other resident servers about the invite if we know about the room
* Correct invite signing
* Fix invite loopback
* Check HTTP response codes, push new invites to front of queue
* Review comments
2020-05-07 11:42:06 +00:00
|
|
|
}
|
|
|
|
|
2022-10-19 10:03:16 +00:00
|
|
|
const maxJitterMultiplier = 1.4
|
|
|
|
const minJitterMultiplier = 0.8
|
|
|
|
|
2020-08-20 13:58:53 +00:00
|
|
|
// duration returns how long the next backoff interval should be.
|
|
|
|
func (s *ServerStatistics) duration(count uint32) time.Duration {
|
2022-10-19 10:03:16 +00:00
|
|
|
// Add some jitter to minimise the chance of having multiple backoffs
|
|
|
|
// ending at the same time.
|
|
|
|
jitter := rand.Float64()*(maxJitterMultiplier-minJitterMultiplier) + minJitterMultiplier
|
|
|
|
duration := time.Millisecond * time.Duration(math.Exp2(float64(count))*jitter*1000)
|
|
|
|
return duration
|
2020-08-20 13:58:53 +00:00
|
|
|
}
|
|
|
|
|
2020-09-21 12:30:37 +00:00
|
|
|
// cancel will interrupt the currently active backoff.
|
|
|
|
func (s *ServerStatistics) cancel() {
|
|
|
|
s.blacklisted.Store(false)
|
|
|
|
s.backoffUntil.Store(time.Time{})
|
2022-10-19 10:03:16 +00:00
|
|
|
|
|
|
|
s.ClearBackoff()
|
|
|
|
}
|
|
|
|
|
|
|
|
// AssignBackoffNotifier configures the channel to send to when
|
|
|
|
// a backoff completes.
|
|
|
|
func (s *ServerStatistics) AssignBackoffNotifier(notifier func()) {
|
|
|
|
s.notifierMutex.Lock()
|
|
|
|
defer s.notifierMutex.Unlock()
|
|
|
|
s.backoffNotifier = notifier
|
2020-09-21 12:30:37 +00:00
|
|
|
}
|
|
|
|
|
Improve federation sender performance, implement backoff and blacklisting, fix up invites a bit (#1007)
* Improve federation sender performance and behaviour, add backoff
* Tweaks
* Tweaks
* Tweaks
* Take copies of events before passing to destination queues
* Don't accidentally drop queued messages
* Don't take copies again
* Tidy up a bit
* Break out statistics (tracked component-wide), report success and failures from Perform actions
* Fix comment, use atomic add
* Improve logic a bit, don't block on wakeup, move idle check
* Don't retry sucessful invites, don't dispatch sendEvent, sendInvite etc
* Dedupe destinations, fix other bug hopefully
* Dispatch sends again
* Federation sender to ignore invites that are destined locally
* Loopback invite events
* Remodel a bit with channels
* Linter
* Only loopback invite event if we know the room
* We should tell other resident servers about the invite if we know about the room
* Correct invite signing
* Fix invite loopback
* Check HTTP response codes, push new invites to front of queue
* Review comments
2020-05-07 11:42:06 +00:00
|
|
|
// Success updates the server statistics with a new successful
|
|
|
|
// attempt, which increases the sent counter and resets the idle and
|
|
|
|
// failure counters. If a host was blacklisted at this point then
|
|
|
|
// we will unblacklist it.
|
|
|
|
func (s *ServerStatistics) Success() {
|
2020-09-21 12:30:37 +00:00
|
|
|
s.cancel()
|
2022-10-13 15:06:50 +00:00
|
|
|
s.backoffCount.Store(0)
|
2022-10-19 10:03:16 +00:00
|
|
|
s.successCounter.Inc()
|
2020-08-07 17:50:29 +00:00
|
|
|
if s.statistics.DB != nil {
|
|
|
|
if err := s.statistics.DB.RemoveServerFromBlacklist(s.serverName); err != nil {
|
|
|
|
logrus.WithError(err).Errorf("Failed to remove %q from blacklist", s.serverName)
|
|
|
|
}
|
2020-07-22 16:01:29 +00:00
|
|
|
}
|
Improve federation sender performance, implement backoff and blacklisting, fix up invites a bit (#1007)
* Improve federation sender performance and behaviour, add backoff
* Tweaks
* Tweaks
* Tweaks
* Take copies of events before passing to destination queues
* Don't accidentally drop queued messages
* Don't take copies again
* Tidy up a bit
* Break out statistics (tracked component-wide), report success and failures from Perform actions
* Fix comment, use atomic add
* Improve logic a bit, don't block on wakeup, move idle check
* Don't retry sucessful invites, don't dispatch sendEvent, sendInvite etc
* Dedupe destinations, fix other bug hopefully
* Dispatch sends again
* Federation sender to ignore invites that are destined locally
* Loopback invite events
* Remodel a bit with channels
* Linter
* Only loopback invite event if we know the room
* We should tell other resident servers about the invite if we know about the room
* Correct invite signing
* Fix invite loopback
* Check HTTP response codes, push new invites to front of queue
* Review comments
2020-05-07 11:42:06 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 17:50:29 +00:00
|
|
|
// Failure marks a failure and starts backing off if needed.
|
2022-10-19 10:03:16 +00:00
|
|
|
// It will return the time that the current failure
|
2020-08-20 13:58:53 +00:00
|
|
|
// will result in backoff waiting until, and a bool signalling
|
|
|
|
// whether we have blacklisted and therefore to give up.
|
|
|
|
func (s *ServerStatistics) Failure() (time.Time, bool) {
|
2022-10-19 10:03:16 +00:00
|
|
|
// Return immediately if we have blacklisted this node.
|
|
|
|
if s.blacklisted.Load() {
|
|
|
|
return time.Time{}, true
|
|
|
|
}
|
|
|
|
|
2020-08-20 13:58:53 +00:00
|
|
|
// If we aren't already backing off, this call will start
|
2022-10-19 10:03:16 +00:00
|
|
|
// a new backoff period, increase the failure counter and
|
2020-09-21 12:30:37 +00:00
|
|
|
// start a goroutine which will wait out the backoff and
|
|
|
|
// unset the backoffStarted flag when done.
|
2022-09-20 14:01:19 +00:00
|
|
|
if s.backoffStarted.CompareAndSwap(false, true) {
|
2020-09-21 12:30:37 +00:00
|
|
|
if s.backoffCount.Inc() >= s.statistics.FailuresUntilBlacklist {
|
|
|
|
s.blacklisted.Store(true)
|
|
|
|
if s.statistics.DB != nil {
|
|
|
|
if err := s.statistics.DB.AddServerToBlacklist(s.serverName); err != nil {
|
|
|
|
logrus.WithError(err).Errorf("Failed to add %q to blacklist", s.serverName)
|
|
|
|
}
|
|
|
|
}
|
2022-10-19 10:03:16 +00:00
|
|
|
s.ClearBackoff()
|
2020-09-21 12:30:37 +00:00
|
|
|
return time.Time{}, true
|
|
|
|
}
|
|
|
|
|
2022-10-19 10:03:16 +00:00
|
|
|
// We're starting a new back off so work out what the next interval
|
|
|
|
// will be.
|
|
|
|
count := s.backoffCount.Load()
|
|
|
|
until := time.Now().Add(s.duration(count))
|
|
|
|
s.backoffUntil.Store(until)
|
2020-08-20 13:58:53 +00:00
|
|
|
|
2022-10-19 10:03:16 +00:00
|
|
|
s.statistics.backoffMutex.Lock()
|
|
|
|
defer s.statistics.backoffMutex.Unlock()
|
|
|
|
s.statistics.backoffTimers[s.serverName] = time.AfterFunc(time.Until(until), s.backoffFinished)
|
2020-08-20 13:58:53 +00:00
|
|
|
}
|
|
|
|
|
2022-10-19 10:03:16 +00:00
|
|
|
return s.backoffUntil.Load().(time.Time), false
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearBackoff stops the backoff timer for this destination if it is running
|
|
|
|
// and removes the timer from the backoffTimers map.
|
|
|
|
func (s *ServerStatistics) ClearBackoff() {
|
|
|
|
// If the timer is still running then stop it so it's memory is cleaned up sooner.
|
|
|
|
s.statistics.backoffMutex.Lock()
|
|
|
|
defer s.statistics.backoffMutex.Unlock()
|
|
|
|
if timer, ok := s.statistics.backoffTimers[s.serverName]; ok {
|
|
|
|
timer.Stop()
|
2020-08-20 13:58:53 +00:00
|
|
|
}
|
2022-10-19 10:03:16 +00:00
|
|
|
delete(s.statistics.backoffTimers, s.serverName)
|
|
|
|
|
|
|
|
s.backoffStarted.Store(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
// backoffFinished will clear the previous backoff and notify the destination queue.
|
|
|
|
func (s *ServerStatistics) backoffFinished() {
|
|
|
|
s.ClearBackoff()
|
2020-08-20 13:58:53 +00:00
|
|
|
|
2022-10-19 10:03:16 +00:00
|
|
|
// Notify the destinationQueue if one is currently running.
|
|
|
|
s.notifierMutex.Lock()
|
|
|
|
defer s.notifierMutex.Unlock()
|
|
|
|
if s.backoffNotifier != nil {
|
|
|
|
s.backoffNotifier()
|
|
|
|
}
|
2020-08-07 17:50:29 +00:00
|
|
|
}
|
|
|
|
|
2020-08-20 16:03:07 +00:00
|
|
|
// BackoffInfo returns information about the current or previous backoff.
|
|
|
|
// Returns the last backoffUntil time and whether the server is currently blacklisted or not.
|
|
|
|
func (s *ServerStatistics) BackoffInfo() (*time.Time, bool) {
|
|
|
|
until, ok := s.backoffUntil.Load().(time.Time)
|
|
|
|
if ok {
|
|
|
|
return &until, s.blacklisted.Load()
|
|
|
|
}
|
|
|
|
return nil, s.blacklisted.Load()
|
|
|
|
}
|
|
|
|
|
Improve federation sender performance, implement backoff and blacklisting, fix up invites a bit (#1007)
* Improve federation sender performance and behaviour, add backoff
* Tweaks
* Tweaks
* Tweaks
* Take copies of events before passing to destination queues
* Don't accidentally drop queued messages
* Don't take copies again
* Tidy up a bit
* Break out statistics (tracked component-wide), report success and failures from Perform actions
* Fix comment, use atomic add
* Improve logic a bit, don't block on wakeup, move idle check
* Don't retry sucessful invites, don't dispatch sendEvent, sendInvite etc
* Dedupe destinations, fix other bug hopefully
* Dispatch sends again
* Federation sender to ignore invites that are destined locally
* Loopback invite events
* Remodel a bit with channels
* Linter
* Only loopback invite event if we know the room
* We should tell other resident servers about the invite if we know about the room
* Correct invite signing
* Fix invite loopback
* Check HTTP response codes, push new invites to front of queue
* Review comments
2020-05-07 11:42:06 +00:00
|
|
|
// Blacklisted returns true if the server is blacklisted and false
|
|
|
|
// otherwise.
|
|
|
|
func (s *ServerStatistics) Blacklisted() bool {
|
|
|
|
return s.blacklisted.Load()
|
|
|
|
}
|
|
|
|
|
2022-10-19 10:03:16 +00:00
|
|
|
// RemoveBlacklist removes the blacklisted status from the server.
|
|
|
|
func (s *ServerStatistics) RemoveBlacklist() {
|
|
|
|
s.cancel()
|
|
|
|
s.backoffCount.Store(0)
|
|
|
|
}
|
|
|
|
|
Improve federation sender performance, implement backoff and blacklisting, fix up invites a bit (#1007)
* Improve federation sender performance and behaviour, add backoff
* Tweaks
* Tweaks
* Tweaks
* Take copies of events before passing to destination queues
* Don't accidentally drop queued messages
* Don't take copies again
* Tidy up a bit
* Break out statistics (tracked component-wide), report success and failures from Perform actions
* Fix comment, use atomic add
* Improve logic a bit, don't block on wakeup, move idle check
* Don't retry sucessful invites, don't dispatch sendEvent, sendInvite etc
* Dedupe destinations, fix other bug hopefully
* Dispatch sends again
* Federation sender to ignore invites that are destined locally
* Loopback invite events
* Remodel a bit with channels
* Linter
* Only loopback invite event if we know the room
* We should tell other resident servers about the invite if we know about the room
* Correct invite signing
* Fix invite loopback
* Check HTTP response codes, push new invites to front of queue
* Review comments
2020-05-07 11:42:06 +00:00
|
|
|
// SuccessCount returns the number of successful requests. This is
|
|
|
|
// usually useful in constructing transaction IDs.
|
|
|
|
func (s *ServerStatistics) SuccessCount() uint32 {
|
|
|
|
return s.successCounter.Load()
|
|
|
|
}
|