From 2bb580c1b09fb927bdd213f8783dc6fa1d7c25f1 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 8 Jul 2020 15:42:36 +0100 Subject: [PATCH] Handle case where pendingPDUs might get out of sync for some reason --- federationsender/queue/destinationqueue.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 }