summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorDavid Robertson <davidr@element.io>2022-07-11 10:36:18 +0100
committerGitHub <noreply@github.com>2022-07-11 10:36:18 +0100
commit28d96cb2b49c12b741d03e4b74f30f8910f9942b (patch)
tree972553d53b117c574b6a8a152539b1fc18ad71f1 /synapse
parenteditorconfig: add max_line_length for Python files (#13228) (diff)
downloadsynapse-28d96cb2b49c12b741d03e4b74f30f8910f9942b.tar.xz
Ensure portdb selects _all_ rows with negative rowids (#13226)
Diffstat (limited to 'synapse')
-rwxr-xr-xsynapse/_scripts/synapse_port_db.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/synapse/_scripts/synapse_port_db.py b/synapse/_scripts/synapse_port_db.py
index 642fd41629..26834a437e 100755
--- a/synapse/_scripts/synapse_port_db.py
+++ b/synapse/_scripts/synapse_port_db.py
@@ -418,12 +418,15 @@ class Porter:
             self.progress.update(table, table_size)  # Mark table as done
             return
 
+        # We sweep over rowids in two directions: one forwards (rowids 1, 2, 3, ...)
+        # and another backwards (rowids 0, -1, -2, ...).
         forward_select = (
             "SELECT rowid, * FROM %s WHERE rowid >= ? ORDER BY rowid LIMIT ?" % (table,)
         )
 
         backward_select = (
-            "SELECT rowid, * FROM %s WHERE rowid <= ? ORDER BY rowid LIMIT ?" % (table,)
+            "SELECT rowid, * FROM %s WHERE rowid <= ? ORDER BY rowid DESC LIMIT ?"
+            % (table,)
         )
 
         do_forward = [True]