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

Commit

Permalink
Also handle the case where we load current IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Sep 24, 2020
1 parent 16b064b commit 91cc36c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion synapse/storage/util/id_generators.py
Expand Up @@ -287,8 +287,12 @@ def _load_current_ids(
min_stream_id = min(self._current_positions.values(), default=None)

if min_stream_id is None:
# We add a GREATEST here to ensure that the result is always
# positive. (This can be a problem for e.g. backfill streams where
# the server has never backfilled).
sql = """
SELECT COALESCE(%(agg)s(%(id)s), 1) FROM %(table)s
SELECT GREATEST(COALESCE(%(agg)s(%(id)s), 1), 1)
FROM %(table)s
""" % {
"id": id_column,
"table": table,
Expand Down

0 comments on commit 91cc36c

Please sign in to comment.