aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-09-01 20:35:38 +0100
committerGitHub <noreply@github.com>2020-09-01 20:35:38 +0100
commit82a96176599aad737e5052a501442b29a5be5c69 (patch)
treea0c454b74bf1659df0ecd8024e9cdd3e192c46b8
parenta9f4d83d30a1305842af594702cc4f99d24f276e (diff)
Put redactions/filters in the writer goroutine (#1378)
* Put redactions in the writer goroutine * Update filters on writer goroutine
-rw-r--r--syncapi/storage/shared/syncserver.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/syncapi/storage/shared/syncserver.go b/syncapi/storage/shared/syncserver.go
index 3388473a..255fe6b5 100644
--- a/syncapi/storage/shared/syncserver.go
+++ b/syncapi/storage/shared/syncserver.go
@@ -525,7 +525,13 @@ func (d *Database) GetFilter(
func (d *Database) PutFilter(
ctx context.Context, localpart string, filter *gomatrixserverlib.Filter,
) (string, error) {
- return d.Filter.InsertFilter(ctx, filter, localpart)
+ var filterID string
+ var err error
+ err = d.Writer.Do(nil, nil, func(txn *sql.Tx) error {
+ filterID, err = d.Filter.InsertFilter(ctx, filter, localpart)
+ return err
+ })
+ return filterID, err
}
func (d *Database) IncrementalSync(
@@ -587,7 +593,10 @@ func (d *Database) RedactEvent(ctx context.Context, redactedEventID string, reda
}
newEvent := ev.Headered(redactedBecause.RoomVersion)
- return d.OutputEvents.UpdateEventJSON(ctx, &newEvent)
+ err = d.Writer.Do(nil, nil, func(txn *sql.Tx) error {
+ return d.OutputEvents.UpdateEventJSON(ctx, &newEvent)
+ })
+ return err
}
// getResponseWithPDUsForCompleteSync creates a response and adds all PDUs needed