From fcdb90c91bb04636bcbb5016a3d197478c3622e3 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 1 Sep 2020 19:21:33 +0100 Subject: [PATCH 1/2] Put redactions in the writer goroutine --- syncapi/storage/shared/syncserver.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/syncapi/storage/shared/syncserver.go b/syncapi/storage/shared/syncserver.go index 3388473ae..47a472bfa 100644 --- a/syncapi/storage/shared/syncserver.go +++ b/syncapi/storage/shared/syncserver.go @@ -587,7 +587,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 From 6410b702ce3ef51086a5b4ff16961debdcf6d2f8 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 1 Sep 2020 19:27:21 +0100 Subject: [PATCH 2/2] Update filters on writer goroutine --- syncapi/storage/shared/syncserver.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/syncapi/storage/shared/syncserver.go b/syncapi/storage/shared/syncserver.go index 47a472bfa..255fe6b58 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(