mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 21:32:46 +00:00
Roomserver per-room input parallelisation (Postgres) (#1289)
* Per-room input mutex * GetMembership should use transaction when assigning state key NID * Actually use writer transactions rather than ignoring them * Limit per-room mutexes to Postgres * Flip the check in InputRoomEvents
This commit is contained in:
parent
0fea056db4
commit
068a3d3c9f
12 changed files with 68 additions and 36 deletions
|
@ -279,9 +279,10 @@ func (s *eventStatements) BulkSelectStateAtEventByID(
|
|||
}
|
||||
|
||||
func (s *eventStatements) UpdateEventState(
|
||||
ctx context.Context, eventNID types.EventNID, stateNID types.StateSnapshotNID,
|
||||
ctx context.Context, txn *sql.Tx, eventNID types.EventNID, stateNID types.StateSnapshotNID,
|
||||
) error {
|
||||
_, err := s.updateEventStateStmt.ExecContext(ctx, int64(stateNID), int64(eventNID))
|
||||
stmt := sqlutil.TxStmt(txn, s.updateEventStateStmt)
|
||||
_, err := stmt.ExecContext(ctx, int64(stateNID), int64(eventNID))
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import (
|
|||
"database/sql"
|
||||
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||
"github.com/matrix-org/dendrite/roomserver/storage/shared"
|
||||
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
||||
)
|
||||
|
@ -65,9 +66,10 @@ func NewSqlitePublishedTable(db *sql.DB) (tables.Published, error) {
|
|||
}
|
||||
|
||||
func (s *publishedStatements) UpsertRoomPublished(
|
||||
ctx context.Context, roomID string, published bool,
|
||||
ctx context.Context, txn *sql.Tx, roomID string, published bool,
|
||||
) error {
|
||||
_, err := s.upsertPublishedStmt.ExecContext(ctx, roomID, published)
|
||||
stmt := sqlutil.TxStmt(txn, s.upsertPublishedStmt)
|
||||
_, err := stmt.ExecContext(ctx, roomID, published)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"database/sql"
|
||||
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||
"github.com/matrix-org/dendrite/roomserver/storage/shared"
|
||||
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
||||
)
|
||||
|
@ -81,9 +82,10 @@ func NewSqliteRoomAliasesTable(db *sql.DB) (tables.RoomAliases, error) {
|
|||
}
|
||||
|
||||
func (s *roomAliasesStatements) InsertRoomAlias(
|
||||
ctx context.Context, alias string, roomID string, creatorUserID string,
|
||||
ctx context.Context, txn *sql.Tx, alias string, roomID string, creatorUserID string,
|
||||
) error {
|
||||
_, err := s.insertRoomAliasStmt.ExecContext(ctx, alias, roomID, creatorUserID)
|
||||
stmt := sqlutil.TxStmt(txn, s.insertRoomAliasStmt)
|
||||
_, err := stmt.ExecContext(ctx, alias, roomID, creatorUserID)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -131,8 +133,9 @@ func (s *roomAliasesStatements) SelectCreatorIDFromAlias(
|
|||
}
|
||||
|
||||
func (s *roomAliasesStatements) DeleteRoomAlias(
|
||||
ctx context.Context, alias string,
|
||||
ctx context.Context, txn *sql.Tx, alias string,
|
||||
) error {
|
||||
_, err := s.deleteRoomAliasStmt.ExecContext(ctx, alias)
|
||||
stmt := sqlutil.TxStmt(txn, s.deleteRoomAliasStmt)
|
||||
_, err := stmt.ExecContext(ctx, alias)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -139,6 +139,14 @@ func Open(dbProperties *config.DatabaseOptions) (*Database, error) {
|
|||
return &d, nil
|
||||
}
|
||||
|
||||
func (d *Database) SupportsConcurrentRoomInputs() bool {
|
||||
// This isn't supported in SQLite mode yet because of issues with
|
||||
// database locks.
|
||||
// TODO: Look at this again - the problem is probably to do with
|
||||
// the membership updaters and latest events updaters.
|
||||
return false
|
||||
}
|
||||
|
||||
func (d *Database) GetLatestEventsForUpdate(
|
||||
ctx context.Context, roomNID types.RoomNID,
|
||||
) (*shared.LatestEventsUpdater, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue