aboutsummaryrefslogtreecommitdiff
path: root/roomserver/storage/postgres/event_json_table.go
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-02-11 17:40:14 +0000
committerGitHub <noreply@github.com>2022-02-11 17:40:14 +0000
commit5106cc807cf22a95420b24f6bfdd5c9ac8aa06de (patch)
treed1da67b5a150ca40a9e572eed6f2550000e0475e /roomserver/storage/postgres/event_json_table.go
parenta4e7d471af7e2cf902404f6740f0932a088cb660 (diff)
Ensure only one transaction is used for RS input per room (#2178)
* Ensure the input API only uses a single transaction * Remove more of the dead query API call * Tidy up * Fix tests hopefully * Don't do unnecessary work for rooms that don't exist * Improve error, fix another case where transaction wasn't used properly * Add a unit test for checking single transaction on RS input API * Fix logic oops when deciding whether to use a transaction in storeEvent
Diffstat (limited to 'roomserver/storage/postgres/event_json_table.go')
-rw-r--r--roomserver/storage/postgres/event_json_table.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/roomserver/storage/postgres/event_json_table.go b/roomserver/storage/postgres/event_json_table.go
index 433e445d..b3220eff 100644
--- a/roomserver/storage/postgres/event_json_table.go
+++ b/roomserver/storage/postgres/event_json_table.go
@@ -76,7 +76,8 @@ func prepareEventJSONTable(db *sql.DB) (tables.EventJSON, error) {
func (s *eventJSONStatements) InsertEventJSON(
ctx context.Context, txn *sql.Tx, eventNID types.EventNID, eventJSON []byte,
) error {
- _, err := s.insertEventJSONStmt.ExecContext(ctx, int64(eventNID), eventJSON)
+ stmt := sqlutil.TxStmt(txn, s.insertEventJSONStmt)
+ _, err := stmt.ExecContext(ctx, int64(eventNID), eventJSON)
return err
}