Summary
extenddb init writes a PostgreSQL connection string into extenddb.toml and into the catalog settings.data_database_connection_string field that fails to parse at daemon startup. Following the documented peer-authentication path in docs/getting-started.md produces an install the daemon refuses to start.
Repro
Ubuntu 24.04, fresh Postgres 16:
sudo apt-get install -y postgresql postgresql-contrib
echo 'local all extenddb scram-sha-256' \
| sudo tee -a /etc/postgresql/16/main/pg_hba.conf
sudo systemctl reload postgresql
cargo build --release
./target/release/extenddb init \
--pg-host /var/run/postgresql \
--extenddb-pass 'extenddb-test-pw'
# init succeeds, prints admin credentials, writes extenddb.toml
./target/release/extenddb serve --config extenddb.toml
# Server failed to start: daemon process exited during startup.
sudo journalctl -t extenddb -n 5
# extenddb fatal: Failed to connect to postgres: Connection error:
# error with configuration: empty host
What init wrote
extenddb.toml:
[storage.postgres]
connection_string = "postgresql://extenddb:***@/var/run/postgresql:5432/extenddb_catalog"
extenddb_catalog.settings:
data_database_connection_string |
postgresql://extenddb:***@/var/run/postgresql:5432/extenddb
The @/var/run/postgresql:5432/ segment is the problem. Unencoded forward slashes in the host portion make the URL ambiguous, and the sqlx/libpq parser the daemon uses rejects it with empty host. The init code apparently builds its connection from discrete --pg-host/--pg-port flags rather than from the URL it later writes, so init succeeds and the daemon fails.
Workaround
After hitting this, the user has to:
- Edit
extenddb.toml to change the connection string.
psql extenddb_catalog -c "UPDATE settings SET value=... WHERE key='data_database_connection_string';" to fix the data-database connection string the daemon reads separately.
After both edits, the daemon starts.
Suggested fix
The connection-string assembly should either percent-encode the host portion (postgresql://extenddb:***@%2Fvar%2Frun%2Fpostgresql:5432/extenddb_catalog) or use the host= parameter form (postgresql://extenddb:***@localhost:5432/extenddb_catalog?host=/var/run/postgresql). A test that round-trips a generated URL through sqlx::postgres::PgConnectOptions::from_url would catch this.
Environment
- ExtendDB: v0.1.0 (HEAD as of release tag)
- OS: Ubuntu 24.04.4 LTS, aarch64
- PostgreSQL: 16.13 (Ubuntu 16.13-0ubuntu0.24.04.1)
- Rust: 1.94.1
Summary
extenddb initwrites a PostgreSQL connection string intoextenddb.tomland into the catalogsettings.data_database_connection_stringfield that fails to parse at daemon startup. Following the documented peer-authentication path indocs/getting-started.mdproduces an install the daemon refuses to start.Repro
Ubuntu 24.04, fresh Postgres 16:
What
initwroteextenddb.toml:extenddb_catalog.settings:The
@/var/run/postgresql:5432/segment is the problem. Unencoded forward slashes in the host portion make the URL ambiguous, and thesqlx/libpqparser the daemon uses rejects it withempty host. The init code apparently builds its connection from discrete--pg-host/--pg-portflags rather than from the URL it later writes, so init succeeds and the daemon fails.Workaround
After hitting this, the user has to:
extenddb.tomlto change the connection string.psql extenddb_catalog -c "UPDATE settings SET value=... WHERE key='data_database_connection_string';"to fix the data-database connection string the daemon reads separately.After both edits, the daemon starts.
Suggested fix
The connection-string assembly should either percent-encode the host portion (
postgresql://extenddb:***@%2Fvar%2Frun%2Fpostgresql:5432/extenddb_catalog) or use thehost=parameter form (postgresql://extenddb:***@localhost:5432/extenddb_catalog?host=/var/run/postgresql). A test that round-trips a generated URL throughsqlx::postgres::PgConnectOptions::from_urlwould catch this.Environment