From d99dd4c1e487be8536c55c51d01a86ebe66a307e Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 10 Sep 2024 14:07:50 +0100 Subject: [PATCH] Fast-path for have_completed_background_updates --- synapse/storage/background_updates.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/synapse/storage/background_updates.py b/synapse/storage/background_updates.py index efe4238036..a4d5943d60 100644 --- a/synapse/storage/background_updates.py +++ b/synapse/storage/background_updates.py @@ -495,6 +495,12 @@ class BackgroundUpdater: if self._all_done: return True + # We now check if we have completed all pending background updates. We + # do this as once this returns True then it will set `self._all_done` + # and we can skip checking the database in future. + if await self.has_completed_background_updates(): + return True + rows = await self.db_pool.simple_select_many_batch( table="background_updates", column="update_name",