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.
This commit is contained in:
Erik Johnston 2020-10-14 15:40:06 +01:00 committed by GitHub
parent 1cf4a68108
commit 618d405a32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 7 deletions

1
changelog.d/8530.bugfix Normal file
View File

@ -0,0 +1 @@
Fix rare bug where sending an event would fail due to a racey assertion.

View File

@ -618,14 +618,7 @@ class _MultiWriterCtxManager:
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: