mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-25 21:21:35 +00:00
Always call overridden form of GetLatestEventsForUpdate (#1554)
This ensures we don't make txns on sqlite still, which can cause 'database is locked' errors.
This commit is contained in:
parent
7612f64e3c
commit
6b8791b868
@ -27,23 +27,24 @@ import (
|
|||||||
const redactionsArePermanent = true
|
const redactionsArePermanent = true
|
||||||
|
|
||||||
type Database struct {
|
type Database struct {
|
||||||
DB *sql.DB
|
DB *sql.DB
|
||||||
Cache caching.RoomServerCaches
|
Cache caching.RoomServerCaches
|
||||||
Writer sqlutil.Writer
|
Writer sqlutil.Writer
|
||||||
EventsTable tables.Events
|
EventsTable tables.Events
|
||||||
EventJSONTable tables.EventJSON
|
EventJSONTable tables.EventJSON
|
||||||
EventTypesTable tables.EventTypes
|
EventTypesTable tables.EventTypes
|
||||||
EventStateKeysTable tables.EventStateKeys
|
EventStateKeysTable tables.EventStateKeys
|
||||||
RoomsTable tables.Rooms
|
RoomsTable tables.Rooms
|
||||||
TransactionsTable tables.Transactions
|
TransactionsTable tables.Transactions
|
||||||
StateSnapshotTable tables.StateSnapshot
|
StateSnapshotTable tables.StateSnapshot
|
||||||
StateBlockTable tables.StateBlock
|
StateBlockTable tables.StateBlock
|
||||||
RoomAliasesTable tables.RoomAliases
|
RoomAliasesTable tables.RoomAliases
|
||||||
PrevEventsTable tables.PreviousEvents
|
PrevEventsTable tables.PreviousEvents
|
||||||
InvitesTable tables.Invites
|
InvitesTable tables.Invites
|
||||||
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
|
||||||
|
@ -120,23 +120,24 @@ func Open(dbProperties *config.DatabaseOptions, cache caching.RoomServerCaches)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
d.Database = shared.Database{
|
d.Database = shared.Database{
|
||||||
DB: d.db,
|
DB: d.db,
|
||||||
Cache: cache,
|
Cache: cache,
|
||||||
Writer: d.writer,
|
Writer: d.writer,
|
||||||
EventsTable: d.events,
|
EventsTable: d.events,
|
||||||
EventTypesTable: d.eventTypes,
|
EventTypesTable: d.eventTypes,
|
||||||
EventStateKeysTable: d.eventStateKeys,
|
EventStateKeysTable: d.eventStateKeys,
|
||||||
EventJSONTable: d.eventJSON,
|
EventJSONTable: d.eventJSON,
|
||||||
RoomsTable: d.rooms,
|
RoomsTable: d.rooms,
|
||||||
TransactionsTable: d.transactions,
|
TransactionsTable: d.transactions,
|
||||||
StateBlockTable: stateBlock,
|
StateBlockTable: stateBlock,
|
||||||
StateSnapshotTable: stateSnapshot,
|
StateSnapshotTable: stateSnapshot,
|
||||||
PrevEventsTable: d.prevEvents,
|
PrevEventsTable: d.prevEvents,
|
||||||
RoomAliasesTable: roomAliases,
|
RoomAliasesTable: roomAliases,
|
||||||
InvitesTable: d.invites,
|
InvitesTable: d.invites,
|
||||||
MembershipTable: d.membership,
|
MembershipTable: d.membership,
|
||||||
PublishedTable: published,
|
PublishedTable: published,
|
||||||
RedactionsTable: redactions,
|
RedactionsTable: redactions,
|
||||||
|
GetLatestEventsForUpdateFn: d.GetLatestEventsForUpdate,
|
||||||
}
|
}
|
||||||
return &d, nil
|
return &d, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user