diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-09-03 21:17:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-03 21:17:55 +0100 |
commit | 04bc09f591ec9562bf7070fb45a8c1c5979e686f (patch) | |
tree | 359184de9c8d0f8e5e510585f7253c856a6f8b79 /federationsender | |
parent | 33b8143a9597ff8c6b75ea47a588d50dc6e72259 (diff) |
Defer keyserver and federationsender wakeups to give HTTP listeners time to start (#1389)
Diffstat (limited to 'federationsender')
-rw-r--r-- | federationsender/queue/queue.go | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/federationsender/queue/queue.go b/federationsender/queue/queue.go index 6561251d..b13df612 100644 --- a/federationsender/queue/queue.go +++ b/federationsender/queue/queue.go @@ -20,6 +20,7 @@ import ( "encoding/json" "fmt" "sync" + "time" stateapi "github.com/matrix-org/dendrite/currentstateserver/api" "github.com/matrix-org/dendrite/federationsender/statistics" @@ -65,26 +66,28 @@ func NewOutgoingQueues( queues: map[gomatrixserverlib.ServerName]*destinationQueue{}, } // Look up which servers we have pending items for and then rehydrate those queues. - serverNames := map[gomatrixserverlib.ServerName]struct{}{} - if names, err := db.GetPendingPDUServerNames(context.Background()); err == nil { - for _, serverName := range names { - serverNames[serverName] = struct{}{} + time.AfterFunc(time.Second*5, func() { + serverNames := map[gomatrixserverlib.ServerName]struct{}{} + if names, err := db.GetPendingPDUServerNames(context.Background()); err == nil { + for _, serverName := range names { + serverNames[serverName] = struct{}{} + } + } else { + log.WithError(err).Error("Failed to get PDU server names for destination queue hydration") } - } else { - log.WithError(err).Error("Failed to get PDU server names for destination queue hydration") - } - if names, err := db.GetPendingEDUServerNames(context.Background()); err == nil { - for _, serverName := range names { - serverNames[serverName] = struct{}{} + if names, err := db.GetPendingEDUServerNames(context.Background()); err == nil { + for _, serverName := range names { + serverNames[serverName] = struct{}{} + } + } else { + log.WithError(err).Error("Failed to get EDU server names for destination queue hydration") } - } else { - log.WithError(err).Error("Failed to get EDU server names for destination queue hydration") - } - for serverName := range serverNames { - if !queues.getQueue(serverName).statistics.Blacklisted() { - queues.getQueue(serverName).wakeQueueIfNeeded() + for serverName := range serverNames { + if !queues.getQueue(serverName).statistics.Blacklisted() { + queues.getQueue(serverName).wakeQueueIfNeeded() + } } - } + }) return queues } |