aboutsummaryrefslogtreecommitdiff
path: root/currentstateserver/storage/sqlite3/current_room_state_table.go
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-09-01 16:58:21 +0100
committerGitHub <noreply@github.com>2020-09-01 16:58:21 +0100
commita9f4d83d30a1305842af594702cc4f99d24f276e (patch)
tree080da17f0c0dc1bf0a9c2af0d82fac9da37fd1f0 /currentstateserver/storage/sqlite3/current_room_state_table.go
parent89c772fb782361bf4cb533ae7287f7d1dea947f6 (diff)
Fix duplicate writers (#1376)
* Fix writers * Don't use writers in both shared and sqlite3
Diffstat (limited to 'currentstateserver/storage/sqlite3/current_room_state_table.go')
-rw-r--r--currentstateserver/storage/sqlite3/current_room_state_table.go38
1 files changed, 16 insertions, 22 deletions
diff --git a/currentstateserver/storage/sqlite3/current_room_state_table.go b/currentstateserver/storage/sqlite3/current_room_state_table.go
index c6cf40ed..1985bf42 100644
--- a/currentstateserver/storage/sqlite3/current_room_state_table.go
+++ b/currentstateserver/storage/sqlite3/current_room_state_table.go
@@ -83,7 +83,6 @@ const selectKnownUsersSQL = "" +
type currentRoomStateStatements struct {
db *sql.DB
- writer sqlutil.Writer
upsertRoomStateStmt *sql.Stmt
deleteRoomStateByEventIDStmt *sql.Stmt
selectRoomIDsWithMembershipStmt *sql.Stmt
@@ -95,8 +94,7 @@ type currentRoomStateStatements struct {
func NewSqliteCurrentRoomStateTable(db *sql.DB) (tables.CurrentRoomState, error) {
s := &currentRoomStateStatements{
- db: db,
- writer: sqlutil.NewExclusiveWriter(),
+ db: db,
}
_, err := db.Exec(currentRoomStateSchema)
if err != nil {
@@ -177,11 +175,9 @@ func (s *currentRoomStateStatements) SelectRoomIDsWithMembership(
func (s *currentRoomStateStatements) DeleteRoomStateByEventID(
ctx context.Context, txn *sql.Tx, eventID string,
) error {
- return s.writer.Do(s.db, txn, func(txn *sql.Tx) error {
- stmt := sqlutil.TxStmt(txn, s.deleteRoomStateByEventIDStmt)
- _, err := stmt.ExecContext(ctx, eventID)
- return err
- })
+ stmt := sqlutil.TxStmt(txn, s.deleteRoomStateByEventIDStmt)
+ _, err := stmt.ExecContext(ctx, eventID)
+ return err
}
func (s *currentRoomStateStatements) UpsertRoomState(
@@ -194,20 +190,18 @@ func (s *currentRoomStateStatements) UpsertRoomState(
}
// upsert state event
- return s.writer.Do(s.db, txn, func(txn *sql.Tx) error {
- stmt := sqlutil.TxStmt(txn, s.upsertRoomStateStmt)
- _, err = stmt.ExecContext(
- ctx,
- event.RoomID(),
- event.EventID(),
- event.Type(),
- event.Sender(),
- *event.StateKey(),
- headeredJSON,
- contentVal,
- )
- return err
- })
+ stmt := sqlutil.TxStmt(txn, s.upsertRoomStateStmt)
+ _, err = stmt.ExecContext(
+ ctx,
+ event.RoomID(),
+ event.EventID(),
+ event.Type(),
+ event.Sender(),
+ *event.StateKey(),
+ headeredJSON,
+ contentVal,
+ )
+ return err
}
func (s *currentRoomStateStatements) SelectEventsWithEventIDs(