From b6cc4417cc0e5bf19f3a871a2664445b08ac55d3 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 2 Sep 2020 10:07:49 +0100 Subject: [PATCH] re-add txn to SelectPeeks --- syncapi/storage/shared/syncserver.go | 6 +++--- syncapi/storage/sqlite3/peeks_table.go | 4 ++-- syncapi/storage/tables/interface.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/syncapi/storage/shared/syncserver.go b/syncapi/storage/shared/syncserver.go index 1d2fa12f..f11b00b3 100644 --- a/syncapi/storage/shared/syncserver.go +++ b/syncapi/storage/shared/syncserver.go @@ -675,7 +675,7 @@ func (d *Database) getResponseWithPDUsForCompleteSync( } // Add peeked rooms. - peeks, err := d.Peeks.SelectPeeks(ctx, userID, deviceID) + peeks, err := d.Peeks.SelectPeeks(ctx, txn, userID, deviceID) if err != nil { return } @@ -1012,7 +1012,7 @@ func (d *Database) getStateDeltas( // find out which rooms this user is peeking, if any. // We do this before joins so any peeks get overwritten - peeks, err := d.Peeks.SelectPeeks(ctx, userID, device.ID) + peeks, err := d.Peeks.SelectPeeks(ctx, txn, userID, device.ID) if err != nil { return nil, nil, err } @@ -1122,7 +1122,7 @@ func (d *Database) getStateDeltasForFullStateSync( return nil, nil, err } - peeks, err := d.Peeks.SelectPeeks(ctx, userID, device.ID) + peeks, err := d.Peeks.SelectPeeks(ctx, txn, userID, device.ID) if err != nil { return nil, nil, err } diff --git a/syncapi/storage/sqlite3/peeks_table.go b/syncapi/storage/sqlite3/peeks_table.go index 8fb74341..c013a635 100644 --- a/syncapi/storage/sqlite3/peeks_table.go +++ b/syncapi/storage/sqlite3/peeks_table.go @@ -136,9 +136,9 @@ func (s *peekStatements) DeletePeeks( } func (s *peekStatements) SelectPeeks( - ctx context.Context, userID, deviceID string, + ctx context.Context, txn *sql.Tx, userID, deviceID string, ) (peeks []types.Peek, err error) { - rows, err := s.selectPeeksStmt.QueryContext(ctx, userID, deviceID) + rows, err := sqlutil.TxStmt(txn, s.selectPeeksStmt).QueryContext(ctx, userID, deviceID) if err != nil { return } diff --git a/syncapi/storage/tables/interface.go b/syncapi/storage/tables/interface.go index 3ca374e4..1f8663b9 100644 --- a/syncapi/storage/tables/interface.go +++ b/syncapi/storage/tables/interface.go @@ -43,7 +43,7 @@ type Peeks interface { InsertPeek(ctx context.Context, txn *sql.Tx, roomID, userID, deviceID string) (streamPos types.StreamPosition, err error) DeletePeek(ctx context.Context, txn *sql.Tx, roomID, userID, deviceID string) (streamPos types.StreamPosition, err error) DeletePeeks(ctx context.Context, txn *sql.Tx, roomID, userID string) (streamPos types.StreamPosition, err error) - SelectPeeks(ctxt context.Context, userID, deviceID string) (peeks []types.Peek, err error) + SelectPeeks(ctxt context.Context, txn *sql.Tx, userID, deviceID string) (peeks []types.Peek, err error) SelectPeekingDevices(ctxt context.Context) (peekingDevices map[string][]types.PeekingDevice, err error) MarkPeeksAsOld(ctxt context.Context, txn *sql.Tx, userID, deviceID string) (err error) }