Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix broken background updates when using sqlite with enable_search
Browse files Browse the repository at this point in the history
…off (#12215)

Signed-off-by: Sean Quah <seanq@element.io>
  • Loading branch information
squahtx authored Mar 14, 2022
1 parent 90b2327 commit 8e5706d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog.d/12215.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug introduced in 1.54.0 that broke background updates on sqlite homeservers while search was disabled.
13 changes: 7 additions & 6 deletions synapse/storage/databases/main/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ def __init__(
):
super().__init__(database, db_conn, hs)

if not hs.config.server.enable_search:
return

self.db_pool.updates.register_background_update_handler(
self.EVENT_SEARCH_UPDATE_NAME, self._background_reindex_search
)
Expand Down Expand Up @@ -243,9 +240,13 @@ def reindex_search_txn(txn):

return len(event_search_rows)

result = await self.db_pool.runInteraction(
self.EVENT_SEARCH_UPDATE_NAME, reindex_search_txn
)
if self.hs.config.server.enable_search:
result = await self.db_pool.runInteraction(
self.EVENT_SEARCH_UPDATE_NAME, reindex_search_txn
)
else:
# Don't index anything if search is not enabled.
result = 0

if not result:
await self.db_pool.updates._end_background_update(
Expand Down

0 comments on commit 8e5706d

Please sign in to comment.