Skip to content

Synapse hangs during initial database schema migration on ARM (Raspberry Pi) #19733

@js-blog

Description

@js-blog

Description

Summary

Synapse hangs during initial database schema migration when running on ARM (Raspberry Pi 4).
The same PostgreSQL instance works correctly when accessed by Synapse on amd64.

The process appears to stall during schema delta application and does not progress further.


Environment

  • Synapse version: 1.151.0

  • Python version: 3.12

  • Architecture: ARM64 (Raspberry Pi 4)

  • OS: (Ubuntu 24.04)

  • Deployment: Synapse running in container (Incus)

  • PostgreSQL: 17.x/18.x

  • Version: (please fill)

  • Location: remote (LAN)

  • Network latency: low (same LAN)


Expected behaviour

Synapse should complete database initialisation and continue startup.


Actual behaviour

Synapse hangs during database schema migration and does not proceed.

Logs stop at:


Applying schema deltas for v73
Applying schema 73/01event_failed_pull_attempts.sql
Applying schema 73/02add_pusher_enabled.sql

No further progress is observed.


Reproduction steps

  1. Start Synapse with a fresh PostgreSQL database
  2. Observe logs during initial startup

Command used:


./env/bin/python -m synapse.app.homeserver --config-path homeserver.yaml


Additional observations

  • The issue only occurs when Synapse runs on ARM (Raspberry Pi)
  • Running Synapse on amd64 against the same PostgreSQL instance works correctly
  • Changing connection parameters (connection pool, keepalive, sslmode) does not affect the issue

Database state (PostgreSQL)

Observed PostgreSQL session state during hang:


pid  |        state        | wait_event_type | wait_event | query
------+---------------------+-----------------+------------+------------------------------------------------------------
6012 | idle in transaction | Client          | ClientRead | INSERT INTO applied_schema_deltas (version, file)
VALUES (73,'73/01event_failed_pull_attempts.sql')

This suggests that:

  • The SQL statement has already been executed
  • PostgreSQL is waiting for the client to continue (ClientRead)
  • The process appears to be stuck on the client side (Synapse), not inside PostgreSQL

Additional context

This appears to be related to database initialisation or migration behaviour on ARM rather than connectivity or configuration issues.


Steps to reproduce

  1. Start Synapse with a fresh PostgreSQL database
  2. Observe logs during initial startup

Command used:

./env/bin/python -m synapse.app.homeserver --config-path homeserver.yaml

Homeserver

another

Synapse Version

matrix-synapse 1.151.0

Installation Method

pip (from PyPI)

Database

PostgreSQL 17.x/18.x

Workers

Single process

Platform

rpi4

Configuration

No response

Relevant log output

--------------------------------------------------------------------------------
2026-04-27 04:12:19,800 - synapse.config.logger - 377 - WARNING - main - ***** STARTING SERVER *****
2026-04-27 04:12:19,801 - synapse.config.logger - 378 - WARNING - main - Server /home/synapse/synapse/env/lib/python3.12/site-packages/synapse/app/homeserver.py version 1.151.0
2026-04-27 04:12:19,801 - synapse.config.logger - 383 - WARNING - main - Copyright (c) 2023 New Vector, Inc
2026-04-27 04:12:19,801 - synapse.config.logger - 384 - WARNING - main - Licensed under the AGPL 3.0 license. Website: https://github.com/element-hq/synapse
2026-04-27 04:12:19,801 - synapse.config.logger - 387 - INFO - main - Server hostname: chat.onmypc.org
2026-04-27 04:12:19,802 - synapse.config.logger - 388 - INFO - main - Public Base URL: https://chat.onmypc.org/
2026-04-27 04:12:19,802 - synapse.config.logger - 389 - INFO - main - Instance name: master
2026-04-27 04:12:19,802 - synapse.config.logger - 390 - INFO - main - Twisted reactor: EPollReactor
2026-04-27 04:12:19,802 - synapse.app.homeserver - 417 - INFO - main - Setting up server
2026-04-27 04:12:19,802 - synapse.server - 635 - INFO - main - Setting up.
2026-04-27 04:12:19,853 - synapse.storage.databases - 92 - INFO - main - [database config 'master']: Checking database server
2026-04-27 04:12:19,858 - synapse.storage.databases - 95 - INFO - main - [database config 'master']: Preparing for databases ['main', 'state']
2026-04-27 04:12:19,858 - synapse.storage.prepare_database - 132 - INFO - main - ['main', 'state']: Checking existing schema version
2026-04-27 04:12:19,886 - synapse.storage.prepare_database - 162 - INFO - main - ['main', 'state']: Initialising new database
2026-04-27 04:12:20,730 - synapse.storage.prepare_database - 430 - INFO - main - Applying schema deltas for v73
2026-04-27 04:12:20,733 - synapse.storage.prepare_database - 538 - INFO - main - Applying schema 73/01event_failed_pull_attempts.sql
2026-04-27 04:12:20,746 - synapse.storage.prepare_database - 538 - INFO - main - Applying schema 73/02add_pusher_enabled.sql
2026-04-27 04:27:59,693 - synapse.app._base - 251 - ERROR - main - Exception during startup
Traceback (most recent call last):
  File "/home/synapse/synapse/env/lib/python3.12/site-packages/synapse/storage/prepare_database.py", line 169, in prepare_database
    _setup_new_database(cur, database_engine, databases=databases)
  File "/home/synapse/synapse/env/lib/python3.12/site-packages/synapse/storage/prepare_database.py", line 295, in _setup_new_database
    _upgrade_existing_database(
  File "/home/synapse/synapse/env/lib/python3.12/site-packages/synapse/storage/prepare_database.py", line 539, in _upgrade_existing_database
    database_engine.execute_script_file(cur, absolute_path)
  File "/home/synapse/synapse/env/lib/python3.12/site-packages/synapse/storage/engines/_base.py", line 154, in execute_script_file
    cls.executescript(cursor, f.read())
  File "/home/synapse/synapse/env/lib/python3.12/site-packages/synapse/storage/engines/postgres.py", line 263, in executescript
    cursor.execute(f"COMMIT; BEGIN TRANSACTION; {script}")
  File "/home/synapse/synapse/env/lib/python3.12/site-packages/synapse/storage/database.py", line 458, in execute
    self._do_execute(self.txn.execute, sql, parameters)
  File "/home/synapse/synapse/env/lib/python3.12/site-packages/synapse/storage/database.py", line 520, in _do_execute
    return func(sql, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.OperationalError: could not receive data from server: Connection timed out

Anything else that would be useful to know?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions