Always call overridden form of GetLatestEventsForUpdate (#1554)

This ensures we don't make txns on sqlite still, which can cause
'database is locked' errors.
main
Kegsay 2020-10-20 19:32:33 +01:00 committed by GitHub
parent 7612f64e3c
commit 6b8791b868
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 34 deletions

View File

@ -44,6 +44,7 @@ type Database struct {
MembershipTable tables.Membership MembershipTable tables.Membership
PublishedTable tables.Published PublishedTable tables.Published
RedactionsTable tables.Redactions RedactionsTable tables.Redactions
GetLatestEventsForUpdateFn func(ctx context.Context, roomInfo types.RoomInfo) (*LatestEventsUpdater, error)
} }
func (d *Database) SupportsConcurrentRoomInputs() bool { func (d *Database) SupportsConcurrentRoomInputs() bool {
@ -372,6 +373,9 @@ func (d *Database) MembershipUpdater(
func (d *Database) GetLatestEventsForUpdate( func (d *Database) GetLatestEventsForUpdate(
ctx context.Context, roomInfo types.RoomInfo, ctx context.Context, roomInfo types.RoomInfo,
) (*LatestEventsUpdater, error) { ) (*LatestEventsUpdater, error) {
if d.GetLatestEventsForUpdateFn != nil {
return d.GetLatestEventsForUpdateFn(ctx, roomInfo)
}
txn, err := d.DB.Begin() txn, err := d.DB.Begin()
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -137,6 +137,7 @@ func Open(dbProperties *config.DatabaseOptions, cache caching.RoomServerCaches)
MembershipTable: d.membership, MembershipTable: d.membership,
PublishedTable: published, PublishedTable: published,
RedactionsTable: redactions, RedactionsTable: redactions,
GetLatestEventsForUpdateFn: d.GetLatestEventsForUpdate,
} }
return &d, nil return &d, nil
} }