From b6011d0d87ccbc686e7f6ac2a764a1918352c172 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Thu, 27 Jan 2022 15:52:32 +0000 Subject: [PATCH] Try federation when backfill fails to find events in the database (#2113) * Try to backfill via federation in error cases * Cleaner retry for backfill * Simpler condition --- roomserver/internal/perform/perform_backfill.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/roomserver/internal/perform/perform_backfill.go b/roomserver/internal/perform/perform_backfill.go index f3623de8..081f694a 100644 --- a/roomserver/internal/perform/perform_backfill.go +++ b/roomserver/internal/perform/perform_backfill.go @@ -82,10 +82,14 @@ func (r *Backfiller) PerformBackfill( return err } - // Retrieve events from the list that was filled previously. + // Retrieve events from the list that was filled previously. If we fail to get + // events from the database then attempt once to get them from federation instead. var loadedEvents []*gomatrixserverlib.Event loadedEvents, err = helpers.LoadEvents(ctx, r.DB, resultNIDs) if err != nil { + if _, ok := err.(types.MissingEventError); ok { + return r.backfillViaFederation(ctx, request, response) + } return err }