aboutsummaryrefslogtreecommitdiff
path: root/roomserver/storage/sqlite3/membership_table.go
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-08-19 15:38:27 +0100
committerGitHub <noreply@github.com>2020-08-19 15:38:27 +0100
commitb24747b305a0770fdd746655e702aa1c1c049765 (patch)
tree88d94b762fafb4852421eb243313edbfc96ccfa9 /roomserver/storage/sqlite3/membership_table.go
parent775b04d776ddc06fdee5ece6a407008f00edb7f2 (diff)
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
Diffstat (limited to 'roomserver/storage/sqlite3/membership_table.go')
-rw-r--r--roomserver/storage/sqlite3/membership_table.go26
1 files changed, 10 insertions, 16 deletions
diff --git a/roomserver/storage/sqlite3/membership_table.go b/roomserver/storage/sqlite3/membership_table.go
index 7b69cee3..b3ee69c0 100644
--- a/roomserver/storage/sqlite3/membership_table.go
+++ b/roomserver/storage/sqlite3/membership_table.go
@@ -77,7 +77,6 @@ const updateMembershipSQL = "" +
type membershipStatements struct {
db *sql.DB
- writer *sqlutil.TransactionWriter
insertMembershipStmt *sql.Stmt
selectMembershipForUpdateStmt *sql.Stmt
selectMembershipFromRoomAndTargetStmt *sql.Stmt
@@ -88,10 +87,9 @@ type membershipStatements struct {
updateMembershipStmt *sql.Stmt
}
-func NewSqliteMembershipTable(db *sql.DB, writer *sqlutil.TransactionWriter) (tables.Membership, error) {
+func NewSqliteMembershipTable(db *sql.DB) (tables.Membership, error) {
s := &membershipStatements{
- db: db,
- writer: writer,
+ db: db,
}
_, err := db.Exec(membershipSchema)
if err != nil {
@@ -115,11 +113,9 @@ func (s *membershipStatements) InsertMembership(
roomNID types.RoomNID, targetUserNID types.EventStateKeyNID,
localTarget bool,
) error {
- return s.writer.Do(s.db, txn, func(txn *sql.Tx) error {
- stmt := sqlutil.TxStmt(txn, s.insertMembershipStmt)
- _, err := stmt.ExecContext(ctx, roomNID, targetUserNID, localTarget)
- return err
- })
+ stmt := sqlutil.TxStmt(txn, s.insertMembershipStmt)
+ _, err := stmt.ExecContext(ctx, roomNID, targetUserNID, localTarget)
+ return err
}
func (s *membershipStatements) SelectMembershipForUpdate(
@@ -201,11 +197,9 @@ func (s *membershipStatements) UpdateMembership(
senderUserNID types.EventStateKeyNID, membership tables.MembershipState,
eventNID types.EventNID,
) error {
- return s.writer.Do(s.db, txn, func(txn *sql.Tx) error {
- stmt := sqlutil.TxStmt(txn, s.updateMembershipStmt)
- _, err := stmt.ExecContext(
- ctx, senderUserNID, membership, eventNID, roomNID, targetUserNID,
- )
- return err
- })
+ stmt := sqlutil.TxStmt(txn, s.updateMembershipStmt)
+ _, err := stmt.ExecContext(
+ ctx, senderUserNID, membership, eventNID, roomNID, targetUserNID,
+ )
+ return err
}