Fix get destinations to catch up query. (#9114)

t was doing a sequential scan on `destination_rooms`, which took
minutes.
This commit is contained in:
Erik Johnston 2021-01-14 16:47:21 +00:00 committed by GitHub
parent 7036e24e98
commit 631dd06f2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 13 deletions

1
changelog.d/9114.bugfix Normal file
View File

@ -0,0 +1 @@
Fix bug in federation catchup logic that caused outbound federation to be delayed for large servers after start up. Introduced in v1.21.0.

View File

@ -464,12 +464,10 @@ class TransactionStore(TransactionWorkerStore):
txn: LoggingTransaction, now_time_ms: int, after_destination: Optional[str] txn: LoggingTransaction, now_time_ms: int, after_destination: Optional[str]
) -> List[str]: ) -> List[str]:
q = """ q = """
SELECT destination FROM destinations SELECT DISTINCT destination FROM destinations
WHERE destination IN ( INNER JOIN destination_rooms USING (destination)
SELECT destination FROM destination_rooms WHERE
WHERE destination_rooms.stream_ordering > stream_ordering > last_successful_stream_ordering
destinations.last_successful_stream_ordering
)
AND destination > ? AND destination > ?
AND ( AND (
retry_last_ts IS NULL OR retry_last_ts IS NULL OR