Try to protect GetNextTransactionPDUs (#1350)

main
Neil Alexander 2020-08-27 15:27:12 +01:00 committed by GitHub
parent 034e5d5a55
commit c0f28845f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -21,7 +21,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/gomatrixserverlib"
) )
@ -62,7 +61,12 @@ func (d *Database) GetNextTransactionPDUs(
receipt *Receipt, receipt *Receipt,
err error, 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) transactionID, err = d.FederationSenderQueuePDUs.SelectQueuePDUNextTransactionID(ctx, txn, serverName)
if err != nil { if err != nil {
return fmt.Errorf("SelectQueuePDUNextTransactionID: %w", err) return fmt.Errorf("SelectQueuePDUNextTransactionID: %w", err)