From cef07c4e4ec2077d8bf3d404ce2f76dee69c7fe6 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 1 Jul 2020 10:16:42 +0100 Subject: [PATCH] Clean up transaction properly --- federationsender/queue/destinationqueue.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/federationsender/queue/destinationqueue.go b/federationsender/queue/destinationqueue.go index 72414e8c3..98072b23f 100644 --- a/federationsender/queue/destinationqueue.go +++ b/federationsender/queue/destinationqueue.go @@ -252,14 +252,6 @@ func (oq *destinationQueue) backgroundSend() { oq.transactionID = "" // Clean up the in-memory buffers. oq.cleanPendingEDUs() - // Clean up the transaction in the database. - if err := oq.db.CleanTransactionPDUs( - context.TODO(), - oq.destination, - transactionID, - ); err != nil { - log.WithError(err).Errorf("failed to clean transaction %q for server %q", transactionID, oq.destination) - } } } @@ -359,7 +351,15 @@ func (oq *destinationQueue) nextTransaction( switch e := err.(type) { case nil: // No error was returned so the transaction looks to have - // been successfully sent. + // been successfully sent. Clean up the transaction in the + // database. + if err = oq.db.CleanTransactionPDUs( + context.TODO(), + t.Destination, + t.TransactionID, + ); err != nil { + log.WithError(err).Errorf("failed to clean transaction %q for server %q", transactionID, oq.destination) + } return true, nil case gomatrix.HTTPError: // We received a HTTP error back. In this instance we only