summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-10-02 11:21:52 +0100
committerErik Johnston <erik@matrix.org>2019-10-02 11:45:31 +0100
commitd69fd53f74f693e0ec756eec479f3d51d93fd2aa (patch)
tree3a5805e0abcbd1ae728e7322e79815b49dbbb94b
parentMerge branch 'release-v1.4.0' of github.com:matrix-org/synapse into develop (diff)
downloadsynapse-d69fd53f74f693e0ec756eec479f3d51d93fd2aa.tar.xz
Bound find_next_generated_user_id DB query.
We can easily bound the set of user IDs we pull out of the DB, so lets
do that.
-rw-r--r--synapse/storage/registration.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py
index 241a7be51e..1a859352b6 100644
--- a/synapse/storage/registration.py
+++ b/synapse/storage/registration.py
@@ -493,7 +493,9 @@ class RegistrationWorkerStore(SQLBaseStore):
         """
 
         def _find_next_generated_user_id(txn):
-            txn.execute("SELECT name FROM users")
+            # We bound between '@1' and '@a' to avoid pulling the entire table
+            # out.
+            txn.execute("SELECT name FROM users WHERE '@1' <= name AND name < '@a'")
 
             regex = re.compile(r"^@(\d+):")