From a19eb80c15a5e0054c2f017444e29f140b77f6f3 Mon Sep 17 00:00:00 2001 From: Mathieu Velten Date: Fri, 9 Sep 2022 16:14:29 +0200 Subject: [PATCH] Make sequence cache_invalidation_stream_seq begins at 2 Signed-off-by: Mathieu Velten --- changelog.d/13766.bugfix | 1 + .../schema/main/delta/58/05cache_instance.sql.postgres | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelog.d/13766.bugfix diff --git a/changelog.d/13766.bugfix b/changelog.d/13766.bugfix new file mode 100644 index 000000000000..032c011315db --- /dev/null +++ b/changelog.d/13766.bugfix @@ -0,0 +1 @@ +Make sequence cache_invalidation_stream_seq begins at 2. diff --git a/synapse/storage/schema/main/delta/58/05cache_instance.sql.postgres b/synapse/storage/schema/main/delta/58/05cache_instance.sql.postgres index aa46eb0e1033..6ff9871dafbe 100644 --- a/synapse/storage/schema/main/delta/58/05cache_instance.sql.postgres +++ b/synapse/storage/schema/main/delta/58/05cache_instance.sql.postgres @@ -27,4 +27,7 @@ CREATE TABLE cache_invalidation_stream_by_instance ( CREATE UNIQUE INDEX cache_invalidation_stream_by_instance_id ON cache_invalidation_stream_by_instance(stream_id); -CREATE SEQUENCE cache_invalidation_stream_seq; +-- The sequence needs to begin at 2 because a bunch of code assume that +-- get_next_id_txn will return values >= 2, cf this comment: +-- https://github.com/matrix-org/synapse/blob/b93bd95e8ab64d27ae26841020f62ee61272a5f2/synapse/storage/util/id_generators.py#L344 +CREATE SEQUENCE cache_invalidation_stream_seq MINVALUE 2;