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

Commit

Permalink
Ensure portdb selects _all_ rows with negative rowids (#13226)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Robertson authored Jul 11, 2022
1 parent 739adf1 commit 28d96cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/13226.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a long-standing bug where the `synapse_port_db` script could fail to copy rows with negative row ids.
5 changes: 4 additions & 1 deletion synapse/_scripts/synapse_port_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,15 @@ async def handle_table(
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]
Expand Down

0 comments on commit 28d96cb

Please sign in to comment.