From a2c10b752e7db4c6d440cd19ddfeb0459469351a Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 13 Oct 2020 11:59:01 +0100 Subject: [PATCH 1/2] Remove racey assertion in MultiWriterIDGenerator 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. --- synapse/storage/util/id_generators.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/synapse/storage/util/id_generators.py b/synapse/storage/util/id_generators.py index 3d8da48f2d65..02d71302ea5e 100644 --- a/synapse/storage/util/id_generators.py +++ b/synapse/storage/util/id_generators.py @@ -618,14 +618,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: From ce85232711405f8c3b429ee91eb4ac6f02c86288 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 13 Oct 2020 12:04:43 +0100 Subject: [PATCH 2/2] Newsfile --- changelog.d/8530.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/8530.bugfix diff --git a/changelog.d/8530.bugfix b/changelog.d/8530.bugfix new file mode 100644 index 000000000000..443d88424ead --- /dev/null +++ b/changelog.d/8530.bugfix @@ -0,0 +1 @@ +Fix rare bug where sending an event would fail due to a racey assertion.