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

Commit 20fa83f

Browse files
erikjohnstonclokep
authored andcommitted
Remove racey assertion in MultiWriterIDGenerator (#8530)
We asserted that the IDs returned by postgres sequence was greater than any we had seen, however this is technically racey as we may update the current positions out of order. We now assert that the sequences are correct on startup, so the assertion is no longer really required, so we remove them.
1 parent 58e583e commit 20fa83f

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

changelog.d/8530.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix rare bug where sending an event would fail due to a racey assertion.

synapse/storage/util/id_generators.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -612,14 +612,7 @@ async def __aenter__(self) -> Union[int, List[int]]:
612612
db_autocommit=True,
613613
)
614614

615-
# Assert the fetched ID is actually greater than any ID we've already
616-
# seen. If not, then the sequence and table have got out of sync
617-
# somehow.
618615
with self.id_gen._lock:
619-
assert max(self.id_gen._current_positions.values(), default=0) < min(
620-
self.stream_ids
621-
)
622-
623616
self.id_gen._unfinished_ids.update(self.stream_ids)
624617

625618
if self.multiple_ids is None:

0 commit comments

Comments
 (0)