diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2020-07-16 13:54:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-16 13:54:45 +0100 |
commit | a827838706b1b0c36afb1f6d6a44ba69751b2ec6 (patch) | |
tree | 5478da2bd4d2c7ed3d42c0450d2f6dad07da36cf /scripts/synapse_port_db | |
parent | Add some tiny type annotations (#7870) (diff) | |
parent | changelog (diff) | |
download | synapse-a827838706b1b0c36afb1f6d6a44ba69751b2ec6.tar.xz |
Merge pull request #7866 from matrix-org/rav/fix_guest_user_id
Fix guest user registration with lots of client readers
Diffstat (limited to 'scripts/synapse_port_db')
-rwxr-xr-x | scripts/synapse_port_db | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/scripts/synapse_port_db b/scripts/synapse_port_db index 2eb795192f..22a6abd7d2 100755 --- a/scripts/synapse_port_db +++ b/scripts/synapse_port_db @@ -48,6 +48,7 @@ from synapse.storage.data_stores.main.media_repository import ( ) from synapse.storage.data_stores.main.registration import ( RegistrationBackgroundUpdateStore, + find_max_generated_user_id_localpart, ) from synapse.storage.data_stores.main.room import RoomBackgroundUpdateStore from synapse.storage.data_stores.main.roommember import RoomMemberBackgroundUpdateStore @@ -622,8 +623,10 @@ class Porter(object): ) ) - # Step 5. Do final post-processing + # Step 5. Set up sequences + self.progress.set_state("Setting up sequence generators") await self._setup_state_group_id_seq() + await self._setup_user_id_seq() self.progress.done() except Exception as e: @@ -793,6 +796,13 @@ class Porter(object): return self.postgres_store.db.runInteraction("setup_state_group_id_seq", r) + def _setup_user_id_seq(self): + def r(txn): + next_id = find_max_generated_user_id_localpart(txn) + 1 + txn.execute("ALTER SEQUENCE user_id_seq RESTART WITH %s", (next_id,)) + + return self.postgres_store.db.runInteraction("setup_user_id_seq", r) + ############################################## # The following is simply UI stuff |