From c0f28845f8715b13b4df8728909c7a55e0a2c63a Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Thu, 27 Aug 2020 15:27:12 +0100 Subject: [PATCH] Try to protect GetNextTransactionPDUs (#1350) --- federationsender/storage/shared/storage_pdus.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/federationsender/storage/shared/storage_pdus.go b/federationsender/storage/shared/storage_pdus.go index 4b51146d..9ab0b094 100644 --- a/federationsender/storage/shared/storage_pdus.go +++ b/federationsender/storage/shared/storage_pdus.go @@ -21,7 +21,6 @@ import ( "errors" "fmt" - "github.com/matrix-org/dendrite/internal/sqlutil" "github.com/matrix-org/gomatrixserverlib" ) @@ -62,7 +61,12 @@ func (d *Database) GetNextTransactionPDUs( receipt *Receipt, err error, ) { - err = sqlutil.WithTransaction(d.DB, func(txn *sql.Tx) error { + // Strictly speaking this doesn't need to be using the writer + // since we are only performing selects, but since we don't have + // a guarantee of transactional isolation, it's actually useful + // to know in SQLite mode that nothing else is trying to modify + // the database. + err = d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error { transactionID, err = d.FederationSenderQueuePDUs.SelectQueuePDUNextTransactionID(ctx, txn, serverName) if err != nil { return fmt.Errorf("SelectQueuePDUNextTransactionID: %w", err)