From b1ca7d25e439116f67d525e9b16bbf954f70982a Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 2 Aug 2022 15:17:15 +0100 Subject: [PATCH] Try more servers when calling `/state_ids` --- roomserver/internal/input/input_missing.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/roomserver/internal/input/input_missing.go b/roomserver/internal/input/input_missing.go index c78e5d79a..5a871738a 100644 --- a/roomserver/internal/input/input_missing.go +++ b/roomserver/internal/input/input_missing.go @@ -662,9 +662,20 @@ func (t *missingStateReq) lookupMissingStateViaStateIDs(ctx context.Context, roo util.GetLogger(ctx).WithField("room_id", roomID).Infof("lookupMissingStateViaStateIDs %s", eventID) // fetch the state event IDs at the time of the event - stateIDs, err := t.federation.LookupStateIDs(ctx, t.origin, roomID, eventID) + var stateIDs gomatrixserverlib.RespStateIDs + var err error + count := 0 + for _, serverName := range t.servers { + reqctx, cancel := context.WithTimeout(ctx, time.Second*30) + stateIDs, err = t.federation.LookupStateIDs(reqctx, serverName, roomID, eventID) + cancel() + if err == nil { + break + } + count++ + } if err != nil { - return nil, err + return nil, fmt.Errorf("t.federation.LookupStateIDs tried %d server(s), last error: %w", count, err) } // work out which auth/state IDs are missing wantIDs := append(stateIDs.StateEventIDs, stateIDs.AuthEventIDs...)