Skip to content

Commit

Permalink
Add forgotten schema delta (element-hq#17054)
Browse files Browse the repository at this point in the history
This should have been in element-hq#17045. Whoops.
  • Loading branch information
erikjohnston authored and hughns committed Apr 9, 2024
1 parent 82a9dac commit ab23bb7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
1 change: 1 addition & 0 deletions changelog.d/17054.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve database performance by adding a missing index to `access_tokens.refresh_token_id`.
14 changes: 7 additions & 7 deletions synapse/storage/databases/main/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2108,6 +2108,13 @@ def __init__(
unique=False,
)

self.db_pool.updates.register_background_index_update(
update_name="access_tokens_refresh_token_id_idx",
index_name="access_tokens_refresh_token_id_idx",
table="access_tokens",
columns=("refresh_token_id",),
)

async def _background_update_set_deactivated_flag(
self, progress: JsonDict, batch_size: int
) -> int:
Expand Down Expand Up @@ -2266,13 +2273,6 @@ def __init__(
):
super().__init__(database, db_conn, hs)

self.db_pool.updates.register_background_index_update(
update_name="access_tokens_refresh_token_id_idx",
index_name="access_tokens_refresh_token_id_idx",
table="access_tokens",
columns=("refresh_token_id",),
)

self._ignore_unknown_session_error = (
hs.config.server.request_token_inhibit_3pid_errors
)
Expand Down
15 changes: 15 additions & 0 deletions synapse/storage/schema/main/delta/84/04_access_token_index.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--
-- This file is licensed under the Affero General Public License (AGPL) version 3.
--
-- Copyright (C) 2023 New Vector, Ltd
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Affero General Public License as
-- published by the Free Software Foundation, either version 3 of the
-- License, or (at your option) any later version.
--
-- See the GNU Affero General Public License for more details:
-- <https://www.gnu.org/licenses/agpl-3.0.html>.

INSERT INTO background_updates (ordering, update_name, progress_json) VALUES
(8404, 'access_tokens_refresh_token_id_idx', '{}');

0 comments on commit ab23bb7

Please sign in to comment.