Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/19973.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug where Synapse could refuse to start with an `IncorrectDatabaseSetup` error about `stream_positions` being inconsistent with a stream sequence, even though the sequence had just been automatically repaired.
10 changes: 10 additions & 0 deletions synapse/storage/util/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ def check_consistency(
"""
txn.execute(sql)

# Since we just auto-repaired, update `last_value` with the new value
# (otherwise we'd make stale comparisons below)
#
# `setval` returns the value the sequence was set to, and marks the sequence
# as `is_called` (i.e. the next `nextval` will return a value strictly
# greater than it), so this is now the true "last value".
row = txn.fetchone()
assert row is not None
(last_value,) = row

txn.close()

# If we have values in the stream positions table then they have to be
Expand Down
Loading