aboutsummaryrefslogtreecommitdiff
path: root/federationsender
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-07-08 15:42:36 +0100
committerNeil Alexander <neilalexander@users.noreply.github.com>2020-07-08 15:42:36 +0100
commit2bb580c1b09fb927bdd213f8783dc6fa1d7c25f1 (patch)
tree79b029516584dfafb19670114c987c303d030a2e /federationsender
parentaf6bc47f1654cfcb6b4834da08308fe4c6291d36 (diff)
Handle case where pendingPDUs might get out of sync for some reason
Diffstat (limited to 'federationsender')
-rw-r--r--federationsender/queue/destinationqueue.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/federationsender/queue/destinationqueue.go b/federationsender/queue/destinationqueue.go
index 61819deb..7751326c 100644
--- a/federationsender/queue/destinationqueue.go
+++ b/federationsender/queue/destinationqueue.go
@@ -349,7 +349,17 @@ func (oq *destinationQueue) nextTransaction(
// If we didn't get anything from the database and there are no
// pending EDUs then there's nothing to do - stop here.
if len(pdus) == 0 && len(pendingEDUs) == 0 {
- log.Warnf("no pdus/edus for nextTransaction for destination %q", oq.destination)
+ log.Warnf("Expected PDUs/EDUs for destination %q but got none", oq.destination)
+ // This shouldn't really happen but since it has, let's check
+ // how many events are *really* in the database that are waiting.
+ if count, cerr := oq.db.GetPendingPDUCount(
+ context.TODO(),
+ oq.destination,
+ ); cerr == nil {
+ oq.pendingPDUs.Store(count)
+ } else {
+ log.Warnf("Failed to retrieve pending PDU count for %q", oq.destination)
+ }
return false, nil
}