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

Commit

Permalink
Remove racey assertion in MultiWriterIDGenerator (#8530)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
erikjohnston authored and clokep committed Oct 15, 2020
1 parent 58e583e commit 20fa83f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
1 change: 1 addition & 0 deletions changelog.d/8530.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix rare bug where sending an event would fail due to a racey assertion.
7 changes: 0 additions & 7 deletions synapse/storage/util/id_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,14 +612,7 @@ async def __aenter__(self) -> Union[int, List[int]]:
db_autocommit=True,
)

# Assert the fetched ID is actually greater than any ID we've already
# seen. If not, then the sequence and table have got out of sync
# somehow.
with self.id_gen._lock:
assert max(self.id_gen._current_positions.values(), default=0) < min(
self.stream_ids
)

self.id_gen._unfinished_ids.update(self.stream_ids)

if self.multiple_ids is None:
Expand Down

0 comments on commit 20fa83f

Please sign in to comment.