Fix lock errors in federation sender (#1347)

* Fix lock errors in federation sender

* Additional fix to writers
This commit is contained in:
Neil Alexander 2020-08-27 11:05:41 +01:00 committed by GitHub
parent 421b6b2313
commit 7466e6b718
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View file

@ -21,7 +21,6 @@ import (
"errors"
"fmt"
"github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/matrix-org/gomatrixserverlib"
)
@ -33,7 +32,7 @@ func (d *Database) AssociateEDUWithDestination(
serverName gomatrixserverlib.ServerName,
receipt *Receipt,
) error {
return sqlutil.WithTransaction(d.DB, func(txn *sql.Tx) error {
return d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
for _, nid := range receipt.nids {
if err := d.FederationSenderQueueEDUs.InsertQueueEDU(
ctx, // context
@ -60,7 +59,7 @@ func (d *Database) GetNextTransactionEDUs(
receipt *Receipt,
err error,
) {
err = sqlutil.WithTransaction(d.DB, func(txn *sql.Tx) error {
err = d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
nids, err := d.FederationSenderQueueEDUs.SelectQueueEDUs(ctx, txn, serverName, limit)
if err != nil {
return fmt.Errorf("SelectQueueEDUs: %w", err)
@ -99,7 +98,7 @@ func (d *Database) CleanEDUs(
return errors.New("expected receipt")
}
return sqlutil.WithTransaction(d.DB, func(txn *sql.Tx) error {
return d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
if err := d.FederationSenderQueueEDUs.DeleteQueueEDUs(ctx, txn, serverName, receipt.nids); err != nil {
return err
}

View file

@ -34,7 +34,7 @@ func (d *Database) AssociatePDUWithDestination(
serverName gomatrixserverlib.ServerName,
receipt *Receipt,
) error {
return sqlutil.WithTransaction(d.DB, func(txn *sql.Tx) error {
return d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
for _, nid := range receipt.nids {
if err := d.FederationSenderQueuePDUs.InsertQueuePDU(
ctx, // context
@ -111,7 +111,7 @@ func (d *Database) CleanPDUs(
return errors.New("expected receipt")
}
return sqlutil.WithTransaction(d.DB, func(txn *sql.Tx) error {
return d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
if err := d.FederationSenderQueuePDUs.DeleteQueuePDUs(ctx, txn, serverName, receipt.nids); err != nil {
return err
}