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

Commit 12dacec

Browse files
Mathieu Veltensquahtx
andauthored
Make sequence cache_invalidation_stream_seq begin at 2 (#13766)
Signed-off-by: Mathieu Velten <[email protected]> Co-authored-by: Sean Quah <[email protected]>
1 parent 9772e36 commit 12dacec

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

changelog.d/13766.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a long-standing bug where the `cache_invalidation_stream_seq` sequence would begin at 1 instead of 2.

synapse/storage/schema/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
- event_edges.(room_id, is_state) are no longer written to.
7777
- Tables related to groups are dropped.
7878
- Unused column application_services_state.last_txn is dropped
79+
- Cache invalidation stream id sequence now begins at 2 to match code expectation.
7980
"""
8081

8182

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* Copyright 2022 The Matrix.org Foundation C.I.C
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
17+
-- The sequence needs to begin at 2 because a bunch of code assumes that
18+
-- get_next_id_txn will return values >= 2, cf this comment:
19+
-- https://github.com/matrix-org/synapse/blob/b93bd95e8ab64d27ae26841020f62ee61272a5f2/synapse/storage/util/id_generators.py#L344
20+
21+
SELECT setval('cache_invalidation_stream_seq', (
22+
SELECT COALESCE(MAX(last_value), 1) FROM cache_invalidation_stream_seq
23+
));

0 commit comments

Comments
 (0)