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

synapse_port_db: --sqlite-database not parsed correctly #15296

Closed
schmaker opened this issue Mar 20, 2023 · 1 comment
Closed

synapse_port_db: --sqlite-database not parsed correctly #15296

schmaker opened this issue Mar 20, 2023 · 1 comment

Comments

@schmaker
Copy link

Description

With synapse_port_db i have issue that --sqlite-database is not parsed correctly.

Instead of loading file (even with using absolute path)

To make everything work as expected i have to change line 1334 to this:
"database": "/var/lib/synapse/homeserver.db-old".format(args.sqlite_database),

Steps to reproduce

  1. Launch synapse_port_db with expected arguments
  2. If you set correct path, you get error:
    sqlite3.OperationalError: unable to open database file
  3. If you set incorrect path, wierd file is being created:
    'file:homeserverblah.db?mode=rw'

Homeserver

schmaker.eu

Synapse Version

{"server_version":"1.78.0","python_version":"3.10.10"}

Installation Method

Other (please mention below)

Database

SQLite migrating to PgSQL

Workers

Single process

Platform

Arch Linux with Python 3.10

Configuration

No response

Relevant log output

[synapse@SchmaCloud ~]$ python /usr/lib/python3.10/site-packages/synapse/_scripts/synapse_port_db.py --sqlite-database /var/lib/synapse/homeserver.db-old --postgres-config /etc/synapse/homeserver-pgsql.yaml 
2023-03-20 19:35:54,047 - synapse.config.key - 153 - WARNING - This server is configured to use 'matrix.org' as its trusted key server via the
'trusted_key_servers' config option. 'matrix.org' is a good choice for a key
server since it is long-lived, stable and trusted. However, some admins may
wish to use another server for this purpose.

To suppress this warning and continue using 'matrix.org', admins should set
'suppress_key_server_warning' to 'true' in homeserver.yaml.
--------------------------------------------------------------------------------
Preparing sqlite3...
2023-03-20 19:35:54,119 - synapse_port_db - 838 - ERROR - 
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/synapse/_scripts/synapse_port_db.py", line 669, in run
    self.sqlite_store = self.build_db_store(
  File "/usr/lib/python3.10/site-packages/synapse/_scripts/synapse_port_db.py", line 611, in build_db_store
    with make_conn(db_config, engine, "portdb") as db_conn:
  File "/usr/lib/python3.10/site-packages/synapse/storage/database.py", line 151, in make_conn
    native_db_conn = engine.module.connect(**db_params)
sqlite3.OperationalError: unable to open database file
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/synapse/_scripts/synapse_port_db.py", line 669, in run
    self.sqlite_store = self.build_db_store(
  File "/usr/lib/python3.10/site-packages/synapse/_scripts/synapse_port_db.py", line 611, in build_db_store
    with make_conn(db_config, engine, "portdb") as db_conn:
  File "/usr/lib/python3.10/site-packages/synapse/storage/database.py", line 151, in make_conn
    native_db_conn = engine.module.connect(**db_params)
sqlite3.OperationalError: unable to open database file

Anything else that would be useful to know?

If you put wrong file name, then you do not get any error message and wierd named file is being created

[synapse@SchmaCloud ~]$ python /usr/lib/python3.10/site-packages/synapse/_scripts/synapse_port_db.py --sqlite-database homeserverblah.db --postgres-config /etc/synapse/homeserver.yaml 
2023-03-20 20:15:37,236 - synapse.config.key - 153 - WARNING - This server is configured to use 'matrix.org' as its trusted key server via the
'trusted_key_servers' config option. 'matrix.org' is a good choice for a key
server since it is long-lived, stable and trusted. However, some admins may
wish to use another server for this purpose.

To suppress this warning and continue using 'matrix.org', admins should set
'suppress_key_server_warning' to 'true' in homeserver.yaml.
--------------------------------------------------------------------------------
Preparing sqlite3...
2023-03-20 20:15:37,298 - synapse.storage.prepare_database - 120 - INFO - ('main', 'state'): Checking existing schema version
2023-03-20 20:15:37,299 - synapse.storage.prepare_database - 150 - INFO - ('main', 'state'): Initialising new database
2023-03-20 20:15:37,339 - synapse.storage.prepare_database - 416 - INFO - Applying schema deltas for v73
2023-03-20 20:15:37,340 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/01event_failed_pull_attempts.sql
2023-03-20 20:15:37,342 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/02add_pusher_enabled.sql
2023-03-20 20:15:37,345 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/02room_id_indexes_for_purging.sql
2023-03-20 20:15:37,346 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/03pusher_device_id.sql
2023-03-20 20:15:37,348 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/03users_approved_column.sql
2023-03-20 20:15:37,351 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/04partial_join_details.sql
2023-03-20 20:15:37,355 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/04pending_device_list_updates.sql
2023-03-20 20:15:37,356 - synapse.storage.prepare_database - 532 - INFO - Applying engine-specific schema 73/05old_push_actions.sql.sqlite
2023-03-20 20:15:37,359 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/06thread_notifications_thread_id_idx.sql
2023-03-20 20:15:37,360 - synapse.storage.prepare_database - 532 - INFO - Applying engine-specific schema 73/08thread_receipts_non_null.sql.sqlite
2023-03-20 20:15:37,373 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/09partial_joined_via_destination.sql
2023-03-20 20:15:37,377 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/09threads_table.sql
2023-03-20 20:15:37,378 - synapse.storage.prepare_database - 507 - INFO - Running 73/10_update_sqlite_fts4_tokenizer.py:run_create
2023-03-20 20:15:37,430 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/10login_tokens.sql
2023-03-20 20:15:37,432 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/12refactor_device_list_outbound_pokes.sql
2023-03-20 20:15:37,434 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/13add_device_lists_index.sql
2023-03-20 20:15:37,435 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/20_un_partial_stated_room_stream.sql
2023-03-20 20:15:37,436 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/22_rebuild_user_dir_stats.sql
2023-03-20 20:15:37,437 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/22_un_partial_stated_event_stream.sql
2023-03-20 20:15:37,438 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/23_fix_thread_index.sql
2023-03-20 20:15:37,440 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/24_events_jump_to_date_index.sql
2023-03-20 20:15:37,440 - synapse.storage.prepare_database - 524 - INFO - Applying schema 73/25drop_presence.sql
2023-03-20 20:15:37,441 - synapse.storage.prepare_database - 416 - INFO - Applying schema deltas for v74
2023-03-20 20:15:37,442 - synapse.storage.prepare_database - 551 - INFO - Schema now up to date
2023-03-20 20:15:37,444 - synapse.storage.util.id_generators - 92 - INFO - Initialising stream generator for receipts_linearized(stream_id): 1
2023-03-20 20:15:37,445 - synapse.storage.util.id_generators - 92 - INFO - Initialising stream generator for events(stream_ordering): 1
2023-03-20 20:15:37,445 - synapse.storage.util.id_generators - 92 - INFO - Initialising stream generator for events(stream_ordering): -1
2023-03-20 20:15:37,445 - synapse.storage.util.id_generators - 92 - INFO - Initialising stream generator for ex_outlier_stream(event_stream_ordering): -1
2023-03-20 20:15:37,447 - synapse.storage.util.id_generators - 92 - INFO - Initialising stream generator for un_partial_stated_event_stream(stream_id): 1
2023-03-20 20:15:37,448 - synapse.storage.util.id_generators - 92 - INFO - Initialising stream generator for pushers(id): 1
2023-03-20 20:15:37,448 - synapse.storage.util.id_generators - 92 - INFO - Initialising stream generator for deleted_pushers(stream_id): 1
2023-03-20 20:15:37,449 - synapse.storage.util.id_generators - 92 - INFO - Initialising stream generator for push_rules_stream(stream_id): 1
2023-03-20 20:15:37,449 - synapse.storage.util.id_generators - 92 - INFO - Initialising stream generator for push_rules(id): 1
2023-03-20 20:15:37,449 - synapse.storage.util.id_generators - 92 - INFO - Initialising stream generator for push_rules_enable(id): 1
2023-03-20 20:15:37,449 - synapse.storage.util.id_generators - 92 - INFO - Initialising stream generator for room_account_data(stream_id): 1
2023-03-20 20:15:37,450 - synapse.storage.util.id_generators - 92 - INFO - Initialising stream generator for room_tags_revisions(stream_id): 1
2023-03-20 20:15:37,451 - synapse.storage.databases.main.event_push_actions - 1298 - INFO - Searching for stream ordering 1 month ago
2023-03-20 20:15:37,451 - synapse.storage.databases.main.event_push_actions - 1302 - INFO - Found stream ordering 1 month ago: it's 0
2023-03-20 20:15:37,451 - synapse.storage.databases.main.event_push_actions - 1305 - INFO - Searching for stream ordering 1 day ago
2023-03-20 20:15:37,451 - synapse.storage.databases.main.event_push_actions - 1309 - INFO - Found stream ordering 1 day ago: it's 0
Pending background updates exist in the SQLite3 database. Please start Synapse again and wait until every update has finished before running this script.
[synapse@SchmaCloud ~]$ ls -l
total 427969
drwxr-xr-x 2 synapse synapse         2 Dec  6 20:07  bridges
-rw-r--r-- 1 synapse synapse   1740800 Mar 20 20:15 'file:homeserverblah.db?mode=rw'
-rw-r--r-- 1 synapse synapse 465031168 Mar 20 19:26  homeserver.db
-rw-r--r-- 1 synapse synapse 465031168 Mar 20 19:56  homeserver.db-old
-rw-r--r-- 1 synapse synapse  10960779 Mar 20 20:16  homeserver.log
-rw-r--r-- 1 synapse synapse   3919358 Mar 17 23:59  homeserver.log.2023-03-17
-rw-r--r-- 1 synapse synapse 217017431 Mar 18 23:59  homeserver.log.2023-03-18
-rw-r--r-- 1 synapse synapse  19542684 Mar 19 23:59  homeserver.log.2023-03-19
drwxr-xr-x 6 synapse synapse         6 Nov 27 10:40  media_store
-rw-r--r-- 1 synapse synapse        86 Dec  6 19:58  package-lock.json
@clokep
Copy link
Member

clokep commented Mar 20, 2023

Duplicate of #15219.

@clokep clokep closed this as completed Mar 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants