Skip to content

Commit

Permalink
Sliding Sync: Fix _bulk_get_max_event_pos(...) being inefficient (#…
Browse files Browse the repository at this point in the history
…17728)

Fix `_bulk_get_max_event_pos(...)` being inefficient. It kept adding all
of the `batch_results` to the `results` over and over every time we
checked a single room in the batch.

I think we still ended up with the right answer before because we
accumulate `recheck_rooms` and actually recheck them to overwrite the
bad data we wrote to the `results` before.

Introduced in
https://github.com/element-hq/synapse/pull/17606/files#diff-cbd54e4b5a2a1646299d659a2d5884d6cb14e608efd2e1658e72b465bb66e31bR1481
  • Loading branch information
MadLittleMods authored Sep 19, 2024
1 parent af998e6 commit faf5b40
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/17728.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `_bulk_get_max_event_pos` being inefficient.
2 changes: 1 addition & 1 deletion synapse/storage/databases/main/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,7 @@ def bulk_get_max_event_pos_from_sliding_sync_tables_txn(
)
for room_id, stream_ordering in batch_results.items():
if stream_ordering <= now_token.stream:
results.update(batch_results)
results[room_id] = stream_ordering
else:
recheck_rooms.add(room_id)

Expand Down

0 comments on commit faf5b40

Please sign in to comment.