Fix schema delta for servers that have not backfilled (#8396)

Fixes #8395.
This commit is contained in:
Erik Johnston 2020-09-25 09:58:32 +01:00 committed by GitHub
parent c77c4a2fcd
commit 3e87d79e1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View file

@ -287,8 +287,12 @@ class MultiWriterIdGenerator:
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,