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

Commit 16c5d95

Browse files
David Robertsonerikjohnston
andauthored
Optimise the event_push_backfill_thread_id bg job (#14172)
Co-authored-by: Erik Johnston <[email protected]>
1 parent 821f74a commit 16c5d95

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

changelog.d/14172.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix poor performance of the `event_push_backfill_thread_id` background update, which was introduced in Synapse 1.68.0rc1.

synapse/storage/databases/main/event_push_actions.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,15 @@ def add_thread_id_txn(
297297
sql = f"""
298298
UPDATE {table_name}
299299
SET thread_id = 'main'
300-
WHERE stream_ordering <= ? AND thread_id IS NULL
300+
WHERE ? < stream_ordering AND stream_ordering <= ? AND thread_id IS NULL
301301
"""
302-
txn.execute(sql, (max_stream_ordering,))
302+
txn.execute(
303+
sql,
304+
(
305+
start_stream_ordering,
306+
max_stream_ordering,
307+
),
308+
)
303309

304310
# Update progress.
305311
processed_rows = txn.rowcount

0 commit comments

Comments
 (0)