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

Commit

Permalink
Optimise the event_push_backfill_thread_id bg job (#14172)
Browse files Browse the repository at this point in the history
Co-authored-by: Erik Johnston <erik@matrix.org>
  • Loading branch information
David Robertson and erikjohnston authored Oct 13, 2022
1 parent 821f74a commit 16c5d95
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/14172.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix poor performance of the `event_push_backfill_thread_id` background update, which was introduced in Synapse 1.68.0rc1.
10 changes: 8 additions & 2 deletions synapse/storage/databases/main/event_push_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,15 @@ def add_thread_id_txn(
sql = f"""
UPDATE {table_name}
SET thread_id = 'main'
WHERE stream_ordering <= ? AND thread_id IS NULL
WHERE ? < stream_ordering AND stream_ordering <= ? AND thread_id IS NULL
"""
txn.execute(sql, (max_stream_ordering,))
txn.execute(
sql,
(
start_stream_ordering,
max_stream_ordering,
),
)

# Update progress.
processed_rows = txn.rowcount
Expand Down

0 comments on commit 16c5d95

Please sign in to comment.