Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database user permission error prints unhelpful error message. #1360

Closed
thruflo opened this issue Jun 13, 2024 · 2 comments
Closed

Database user permission error prints unhelpful error message. #1360

thruflo opened this issue Jun 13, 2024 · 2 comments

Comments

@thruflo
Copy link
Contributor

thruflo commented Jun 13, 2024

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?

Or similar.

Copy link

linear bot commented Jun 13, 2024

@KyleAMathews
Copy link
Contributor

👋 we've been working the last month on a rebuild of the Electric server over at a temporary repo https://github.com/electric-sql/electric-next/

You can read more about why we made the decision at https://next.electric-sql.com/about

We're really excited about all the new possibilities the new server brings and we hope you'll check it out soon and give us your feedback.

We're now moving the temporary repo back here. As part of that migration we're closing all the old issues and PRs. We really appreciate you taking the time to investigate and report this issue!

@KyleAMathews KyleAMathews closed this as not planned Won't fix, can't repro, duplicate, stale Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants