Transaction writer changes, move roomserver writers (#1285)

* Updated TransactionWriters, moved locks in roomserver, various other tweaks

* Fix redaction deadlocks

* Fix lint issue

* Rename SQLiteTransactionWriter to ExclusiveTransactionWriter

* Fix us not sending transactions through in latest events updater
This commit is contained in:
Neil Alexander 2020-08-19 15:38:27 +01:00 committed by GitHub
parent 775b04d776
commit b24747b305
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
54 changed files with 432 additions and 434 deletions

View file

@ -19,7 +19,6 @@ 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"
)
@ -45,16 +44,14 @@ const selectPublishedSQL = "" +
type publishedStatements struct {
db *sql.DB
writer *sqlutil.TransactionWriter
upsertPublishedStmt *sql.Stmt
selectAllPublishedStmt *sql.Stmt
selectPublishedStmt *sql.Stmt
}
func NewSqlitePublishedTable(db *sql.DB, writer *sqlutil.TransactionWriter) (tables.Published, error) {
func NewSqlitePublishedTable(db *sql.DB) (tables.Published, error) {
s := &publishedStatements{
db: db,
writer: writer,
db: db,
}
_, err := db.Exec(publishedSchema)
if err != nil {
@ -69,12 +66,9 @@ func NewSqlitePublishedTable(db *sql.DB, writer *sqlutil.TransactionWriter) (tab
func (s *publishedStatements) UpsertRoomPublished(
ctx context.Context, roomID string, published bool,
) (err error) {
return s.writer.Do(s.db, nil, func(txn *sql.Tx) error {
stmt := sqlutil.TxStmt(txn, s.upsertPublishedStmt)
_, err := stmt.ExecContext(ctx, roomID, published)
return err
})
) error {
_, err := s.upsertPublishedStmt.ExecContext(ctx, roomID, published)
return err
}
func (s *publishedStatements) SelectPublishedFromRoomID(