Tweaks to backfill
MODIFY
federationapi/routing/backfill.go
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())
}

MODIFY
syncapi/storage/postgres/backward_extremities_table.go
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"

MODIFY
syncapi/storage/sqlite3/backward_extremities_table.go
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"

Tweaks to backfill (#964)