-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
synapse_port_db - Failed to insert: event_edges #13191
Comments
I'm not sure if this is a bug in portdb or if your sqlite database is corrupted. What happens if you stop Synapse and run this query against sqlite? SELECT * from events where event_id='$70n7eZhMwy80aMWDetgskT9nZ4OnAMVb_NVARjMOHpM'; |
|
Thanks. Presumably a portdb bug then. I would guess that we don't make any effort to port over tables that are cited by foreign key constraints before the tables that cite them. |
Feel free to use me as a crash test dummy on debugging. I run the importer again on a more recent snapshot and the event_id is the same. |
Proposed (short term) fix:
|
Although we seemingly already try to do this? synapse/synapse/_scripts/synapse_port_db.py Lines 754 to 780 in b036685
|
What info can I provide to help you out further? I run this against a PostgreSQL (cluster) V12 |
A few questions:
|
Sorry, I meant the sqlite-to-postgres script, but as you say here
you've already been running the script multiple times, which is all I wanted to know.
Thanks, this confirms that we should be trying to port the
Do you have any logs prior to this from running |
Logrotate already ate the logs from the beginning - so I did the next best thing: Stuff I found in there wasn't interesting at all - mostly consisting of Users not being found as in
or Servers down stuff like
No Tracebacks or any other severe things showed up as non-info chatter. |
Sorry, I mean the logs from running
|
Thanks @ToeiRei for providing extra logs and a copy of your database privately. There is something very weird with the way that the portdb script is selecting rows to insert into postgres. It makes two "sweeps" based on sqlite rowids: a forwards and backwards sweep. With some extra debug we can see this more easily.
The reason I say this is weird is that the backward sweep seems to miss out a whole bunch of row ids:
And I note from #13191 (comment) that the missing event has rowid -8558. |
The `backward_select` query uses the `backward_chunk` variable as an inclusive upper bound on the rowids it selects. It is initially 0 (see `setup_table`). It is then set to ``` backward_chunk = min(row[0] for row in brows) - 1 ``` where `brows` is the result of running the `backwards_select` query. For this to make sense, we need to ensure that `backwards_select` picks rows in descending order. Otherwise we'll jump right to the bottom of the rowids, pick out the lowest batch only and discard everything we skipped over. This is a Bad Thing. I've tested this locally with the reproduction case reported in #13191. Without the patch, I could reproduce the reported failure; with the patch, the portdb script completes successfully.
Thanks again for your help in tracking this down. It looks there is an (old!) bug in the portdb script (from before Synapse 1.0.0). #13226 proposes a fix. |
If you want me to test stuff, let me know |
Description
Migrating the database from Sqlite3 to Postgres using the synapse_port_db script I run into an error as follows:
Steps to reproduce
Homeserver
stargazer.at
Synapse Version
{"server":{"name":"Synapse","version":"1.62.0"}}
Installation Method
Debian packages from packages.matrix.org
Platform
Debian 11 in a VM, minimum install
Relevant log output
The text was updated successfully, but these errors were encountered: