From 7b3edf4622fa562a0d8b42c1ac845b88722374f0 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 15 Apr 2020 14:39:27 +0100 Subject: [PATCH] Tweaks to backfill (#964) --- federationapi/routing/backfill.go | 2 +- syncapi/storage/postgres/backward_extremities_table.go | 2 +- syncapi/storage/sqlite3/backward_extremities_table.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/federationapi/routing/backfill.go b/federationapi/routing/backfill.go index 72ce0c66..7092c436 100644 --- a/federationapi/routing/backfill.go +++ b/federationapi/routing/backfill.go @@ -93,7 +93,7 @@ func Backfill( } var eventJSONs []json.RawMessage - for _, e := range evs { + for _, e := range gomatrixserverlib.ReverseTopologicalOrdering(evs) { eventJSONs = append(eventJSONs, e.JSON()) } diff --git a/syncapi/storage/postgres/backward_extremities_table.go b/syncapi/storage/postgres/backward_extremities_table.go index b3ee28e0..cb362964 100644 --- a/syncapi/storage/postgres/backward_extremities_table.go +++ b/syncapi/storage/postgres/backward_extremities_table.go @@ -60,7 +60,7 @@ const insertBackwardExtremitySQL = "" + " ON CONFLICT DO NOTHING" const selectBackwardExtremitiesForRoomSQL = "" + - "SELECT event_id FROM syncapi_backward_extremities WHERE room_id = $1" + "SELECT DISTINCT event_id FROM syncapi_backward_extremities WHERE room_id = $1" const deleteBackwardExtremitySQL = "" + "DELETE FROM syncapi_backward_extremities WHERE room_id = $1 AND prev_event_id = $2" diff --git a/syncapi/storage/sqlite3/backward_extremities_table.go b/syncapi/storage/sqlite3/backward_extremities_table.go index 0663e2a1..3d8cb91f 100644 --- a/syncapi/storage/sqlite3/backward_extremities_table.go +++ b/syncapi/storage/sqlite3/backward_extremities_table.go @@ -60,7 +60,7 @@ const insertBackwardExtremitySQL = "" + " ON CONFLICT (room_id, event_id, prev_event_id) DO NOTHING" const selectBackwardExtremitiesForRoomSQL = "" + - "SELECT event_id FROM syncapi_backward_extremities WHERE room_id = $1" + "SELECT DISTINCT event_id FROM syncapi_backward_extremities WHERE room_id = $1" const deleteBackwardExtremitySQL = "" + "DELETE FROM syncapi_backward_extremities WHERE room_id = $1 AND prev_event_id = $2"