diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py index 5062bf4e47..0d32a3a498 100644 --- a/synapse/storage/stream.py +++ b/synapse/storage/stream.py @@ -828,8 +828,8 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore): rows.extend(new_rows) - if limit > 0: - rows = rows[:limit] + # We may have inserted more rows than necessary in the loop above + rows = rows[:limit] if rows: chunk = rows[-1].chunk_id