Remove assume offline on broadcast received

This commit is contained in:
Devon Hudson 2022-12-02 16:18:48 -07:00
parent 98c7711b84
commit 1df1a597ec
No known key found for this signature in database
GPG key ID: CD06B18E77F6A628
3 changed files with 10 additions and 1 deletions

View file

@ -762,8 +762,11 @@ func (r *FederationInternalAPI) PerformWakeupServers(
func (r *FederationInternalAPI) MarkServersAlive(destinations []gomatrixserverlib.ServerName) {
for _, srv := range destinations {
// Check the statistics cache for the blacklist status to prevent hitting
// Check the statistics cache for the blacklist & assumed offline status to prevent hitting
// the database unnecessarily.
if r.statistics.ForServer(srv).AssumedOffline() {
_ = r.db.RemoveServerAssumedOffline(srv)
}
if r.queues.IsServerBlacklisted(srv) {
_ = r.db.RemoveServerFromBlacklist(srv)
}

View file

@ -388,6 +388,7 @@ func (oqs *OutgoingQueues) RetryServer(srv gomatrixserverlib.ServerName) {
serverStatistics := oqs.statistics.ForServer(srv)
forceWakeup := serverStatistics.Blacklisted()
serverStatistics.RemoveAssumedOffline()
serverStatistics.RemoveBlacklist()
serverStatistics.ClearBackoff()

View file

@ -260,6 +260,11 @@ func (s *ServerStatistics) RemoveBlacklist() {
s.backoffCount.Store(0)
}
// RemoveAssumedOffline removes the assumed offline status from the server.
func (s *ServerStatistics) RemoveAssumedOffline() {
s.assumedOffline.Store(false)
}
// SuccessCount returns the number of successful requests. This is
// usually useful in constructing transaction IDs.
func (s *ServerStatistics) SuccessCount() uint32 {