Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

fix lots of places where we didn't rollback txns upon go errs #1417

Merged
merged 2 commits into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion federationsender/storage/shared/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (d *Database) StoreJSON(
var err error
_ = d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
nid, err = d.FederationSenderQueueJSON.InsertQueueJSON(ctx, txn, js)
return nil
return err
})
if err != nil {
return nil, fmt.Errorf("d.insertQueueJSON: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion keyserver/storage/shared/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (d *Database) ExistingOneTimeKeys(ctx context.Context, userID, deviceID str
func (d *Database) StoreOneTimeKeys(ctx context.Context, keys api.OneTimeKeys) (counts *api.OneTimeKeysCount, err error) {
_ = d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
counts, err = d.OneTimeKeysTable.InsertOneTimeKeys(ctx, txn, keys)
return nil
return err
})
return
}
Expand Down
4 changes: 2 additions & 2 deletions roomserver/storage/shared/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func (d *Database) MembershipUpdater(
var updater *MembershipUpdater
_ = d.Writer.Do(d.DB, txn, func(txn *sql.Tx) error {
updater, err = NewMembershipUpdater(ctx, d, txn, roomID, targetUserID, targetLocal, roomVersion)
return nil
return err
})
return updater, err
}
Expand All @@ -374,7 +374,7 @@ func (d *Database) GetLatestEventsForUpdate(
var updater *LatestEventsUpdater
_ = d.Writer.Do(d.DB, txn, func(txn *sql.Tx) error {
updater, err = NewLatestEventsUpdater(ctx, d, txn, roomInfo)
return nil
return err
})
return updater, err
}
Expand Down
8 changes: 4 additions & 4 deletions syncapi/storage/shared/syncserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (d *Database) AddInviteEvent(
) (sp types.StreamPosition, err error) {
_ = d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
sp, err = d.Invites.InsertInviteEvent(ctx, txn, inviteEvent)
return nil
return err
})
return
}
Expand All @@ -158,7 +158,7 @@ func (d *Database) RetireInviteEvent(
) (sp types.StreamPosition, err error) {
_ = d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
sp, err = d.Invites.DeleteInviteEvent(ctx, txn, inviteEventID)
return nil
return err
})
return
}
Expand All @@ -171,7 +171,7 @@ func (d *Database) AddPeek(
) (sp types.StreamPosition, err error) {
_ = d.Writer.Do(nil, nil, func(_ *sql.Tx) error {
sp, err = d.Peeks.InsertPeek(ctx, nil, roomID, userID, deviceID)
return nil
return err
})
return
}
Expand All @@ -184,7 +184,7 @@ func (d *Database) DeletePeeks(
) (sp types.StreamPosition, err error) {
_ = d.Writer.Do(nil, nil, func(_ *sql.Tx) error {
sp, err = d.Peeks.DeletePeeks(ctx, nil, roomID, userID)
return nil
return err
})
if err == sql.ErrNoRows {
err = nil
Expand Down