aboutsummaryrefslogtreecommitdiff
path: root/roomserver
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-10-07 12:21:38 +0100
committerNeil Alexander <neilalexander@users.noreply.github.com>2022-10-07 12:21:55 +0100
commit8d8f4689a0c71f79051554e69fb9113592a4b2e4 (patch)
treeeffe170071bbfc98da1a7eacb90f2d250aae49b0 /roomserver
parentb9d0e9f7ed7ce1f4be72a25c6f5185a6e809f019 (diff)
tDatabase transaction tweaks in roomserver
Diffstat (limited to 'roomserver')
-rw-r--r--roomserver/storage/shared/storage.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/roomserver/storage/shared/storage.go b/roomserver/storage/shared/storage.go
index d83a1ff7..8859571b 100644
--- a/roomserver/storage/shared/storage.go
+++ b/roomserver/storage/shared/storage.go
@@ -598,7 +598,7 @@ func (d *Database) storeEvent(
}
// First writer is with a database-provided transaction, so that NIDs are assigned
// globally outside of the updater context, to help avoid races.
- err = d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
+ err = d.Writer.Do(d.DB, txn, func(txn *sql.Tx) error {
// TODO: Here we should aim to have two different code paths for new rooms
// vs existing ones.
@@ -964,9 +964,9 @@ func (d *Database) loadRedactionPair(
}
if isRedactionEvent {
- redactedEvent = d.loadEvent(ctx, info.RedactsEventID)
+ redactedEvent = d.loadEvent(ctx, txn, info.RedactsEventID)
} else {
- redactionEvent = d.loadEvent(ctx, info.RedactionEventID)
+ redactionEvent = d.loadEvent(ctx, txn, info.RedactionEventID)
}
return redactionEvent, redactedEvent, info.Validated, nil
@@ -982,15 +982,15 @@ func (d *Database) applyRedactions(events []types.Event) {
}
// loadEvent loads a single event or returns nil on any problems/missing event
-func (d *Database) loadEvent(ctx context.Context, eventID string) *types.Event {
- nids, err := d.EventNIDs(ctx, []string{eventID})
+func (d *Database) loadEvent(ctx context.Context, txn *sql.Tx, eventID string) *types.Event {
+ nids, err := d.eventNIDs(ctx, txn, []string{eventID}, NoFilter)
if err != nil {
return nil
}
if len(nids) == 0 {
return nil
}
- evs, err := d.Events(ctx, []types.EventNID{nids[eventID]})
+ evs, err := d.events(ctx, txn, []types.EventNID{nids[eventID]})
if err != nil {
return nil
}
@@ -1358,7 +1358,7 @@ func (d *Database) ForgetRoom(ctx context.Context, userID, roomID string, forget
}
return d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
- return d.MembershipTable.UpdateForgetMembership(ctx, nil, roomNIDs[0], stateKeyNID, forget)
+ return d.MembershipTable.UpdateForgetMembership(ctx, txn, roomNIDs[0], stateKeyNID, forget)
})
}