The following is a traceback / output from running Electric against a Postgres which doesn't provide CREATE permissions on the database. This means the CREATE SCHEMA statement fails when trying to bootstrap the database with Electric resources.
The error from this is presented as a "connection error" with the detail {:error, %MatchError{term: []}} and a suggestion to "Double-check the value of DATABASE_URL and make sure your database ▓ is running and can be reached using the connection URL in DATABASE_URL."
docker run \
-e "DATABASE_URL=postgresql://..." \
-e "DATABASE_REQUIRE_SSL=true" \
-e "ELECTRIC_WRITE_TO_PG_MODE=direct_writes" \
-e "PG_PROXY_PASSWORD=redacted" \
-e "AUTH_MODE=insecure" \
-p 5133:5133 \
-p 5433:5433 \
-p 65432:65432 \
electricsql/electric
11:16:02.806 pid=<0.3063.0> [info] Starting ElectricSQL 0.12.0 in direct_writes mode.
11:16:02.808 pid=<0.3064.0> [info] Running Electric.Plug.Router with Bandit 1.1.3 at :::5133 (http)
11:16:02.869 pid=<0.3378.0> origin=postgres_1 [warning] Failed to load cacerts from the OS: :enoent
11:16:02.870 pid=<0.3378.0> origin=postgres_1 [info] Postgres.Client.with_conn(%{database: ~c"redacted", host: ~c"redacted", ip_addr: ~c"redacted", ipv6: false, nulls: [nil, :null, :undefined], password: ~c"******", port: 5432, ssl: :required, ssl_opts: [server_name_indication: ~c"redacted"], timeout: 5000, username: ~c"redacted"})
11:16:02.978 pid=<0.3382.0> [warning] Description: ~c"Server authenticity is not verified since certificate path validation is not enabled"
Reason: ~c"The option {verify, verify_peer} and one of the options 'cacertfile' or 'cacerts' are required to enable this."
11:16:03.596 pid=<0.3378.0> origin=postgres_1 [error] ** (MatchError) no match of right hand side value: []
(electric 0.12.0) lib/electric/postgres/extension.ex:469: Electric.Postgres.Extension.create_schema/1
(electric 0.12.0) lib/electric/postgres/extension.ex:410: anonymous fn/3 in Electric.Postgres.Extension.migrate/2
(epgsql 4.7.1) /app/deps/epgsql/src/epgsql.erl:458: :epgsql.with_transaction/3
(electric 0.12.0) lib/electric/replication/postgres_manager.ex:263: anonymous fn/3 in Electric.Replication.PostgresConnectorMng.initialize_postgres/1
(electric 0.12.0) lib/electric/replication/postgres/client.ex:55: Electric.Replication.Postgres.Client.with_conn/2
(electric 0.12.0) lib/electric/replication/postgres_manager.ex:134: Electric.Replication.PostgresConnectorMng.handle_continue/2
(stdlib 4.3.1.3) gen_server.erl:1123: :gen_server.try_dispatch/4
(stdlib 4.3.1.3) gen_server.erl:865: :gen_server.loop/7
11:16:03.597 pid=<0.3378.0> origin=postgres_1 [error] Initialization of Postgres state failed with reason: {:error, %MatchError{term: []}}.
▓ ┌────────────────────┐
▓ │ CONNECTION ERROR │
▓ ┕━━━━━━━━━━━━━━━━━━━━┙
▓
▓ Failed to initialize Postgres state:
▓ {:error, %MatchError{term: []}}
▓
▓ Double-check the value of DATABASE_URL and make sure your database
▓ is running and can be reached using the connection URL in DATABASE_URL.
Now this isn't totally unhelpful because the db user creds are in the database url. However, I suggest that a helpful error message might say something say something like:
Could not create schema. Does your database user have CREATE permission on the database?
The following is a traceback / output from running Electric against a Postgres which doesn't provide CREATE permissions on the database. This means the
CREATE SCHEMA
statement fails when trying to bootstrap the database with Electric resources.The error from this is presented as a "connection error" with the detail
{:error, %MatchError{term: []}}
and a suggestion to "Double-check the value of DATABASE_URL and make sure your database ▓ is running and can be reached using the connection URL in DATABASE_URL."Now this isn't totally unhelpful because the db user creds are in the database url. However, I suggest that a helpful error message might say something say something like:
Or similar.