Blockscout: Following installation instruction in readme results in database connection errors

Created on 28 Jul 2018  路  13Comments  路  Source: blockscout/blockscout

Describe your issue here.

Environment

UBUNTU LTS 18.4

Steps to reproduce

Follow installation instructions in readme.

Expected behaviour

Cannot start explorer

Actual behaviour

I receive command lines scrolling like this:

(connection) lib/connection.ex:622: Connection.enter_connect/5
            (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
    (db_connection) lib/db_connection/poolboy.ex:112: DBConnection.Poolboy.checkout/3
    (db_connection) lib/db_connection.ex:928: DBConnection.checkout/2
    (db_connection) lib/db_connection.ex:750: DBConnection.run/3
    (db_connection) lib/db_connection.ex:592: DBConnection.prepare_execute/4

Are there some Postgres installation instructions that are missing from the readme?

Most helpful comment

I reproduced the issue locally. On Ubuntu, the default authentication for a local user is via an md5 hashed password. One solution is to add a password for the postgres user:

sudo -u postgres psql

At the postgres=# prompt enter (including the backslash):

\password

and follow the new password and confirmation prompts. Enter \q and press return to exit psql.

At this point, you need to edit the apps/explorer/config/dev.secret.exs file and add the database configuration. It will look like this when you're done:

use Mix.Config

# Configure your database
config :explorer, Explorer.Repo,
  adapter: Ecto.Adapters.Postgres,
  database: "explorer_dev",
  hostname: "localhost",
  username: "postgres",
  password: "<REPLACE WITH THE PASSWORD YOU CHOSE>",
  loggers: [],
  pool_size: 20,
  pool_timeout: 60_000,
  timeout: 80_000

@nickjuntilla if you can test this locally, I'll work up a PR adding more detailed documentation to the README so that other Ubuntu users will have clearer instructions.

All 13 comments

Hi @nickjuntilla,

What version of postgres are you using?

There are no other directions for Postgres setup other than on the readme.

Please also make sure to check that postgresql is not installed, there might be a conflict there. If so, do the following:

  1. sudo apt install postgresql postgresql-contrib

@acravenho Can I use brew with ubuntu? I'm using Ubuntu on a server. I don't see any installation instructions for postgres in the readme. I tried to do sudo apt-get install postgres, but no package was found.

@nickjuntilla Sorry, I overlooked your environment. Here are the requirements from the Readme:

  • Erlang/OTP 20.3.2
  • Elixir 1.6.5
  • Postgres 10.3
  • Node.js 10.5.0
  • Automake
  • Libtool

You could attempt using PostgreSQL by trying sudo apt install postgresql postgresql-contrib. This has not been tested yet.

@acravenho I have previously installed postgresql with "sudo apt install postgresql postgresql-contrib"

And it didn't work. That is when I received the errors the first time. Is there a difference on Ubuntu between postgresql and postgres?

What I am really trying to do is just have a server, any server, running this. Is there a server environment that I can install this on besides mac. It doesn't have to be Ubuntu. Anything that works will do. I am using google cloud and can start up a variety of environments, but I can't serve this from a mac because I want to leave it running.

@nickjuntilla I'll launch an instance on Ubuntu today and provide my results.

@nickjuntilla What you posted looks like a partial stacktrace and it's difficult for me to understand the underlying error. It's possible that the database isn't running or is set up with different credentials than the app is expecting. Can you paste the output of mix ecto.create run from the root of the poa-explorer project?

@tmecklem so before or after I install postgresql this way: sudo apt install postgresql postgresql-contrib

then run mix ecto.create

I get the same error:

** (Mix) The database for Explorer.Repo couldn't be created: an exception was raised:
    ** (RuntimeError) Connect raised a KeyError error. The exception details are hidden, as
they may contain sensitive data such as database credentials.

        (elixir) lib/keyword.ex:377: Keyword.fetch!/2
        (postgrex) lib/postgrex/protocol.ex:610: Postgrex.Protocol.auth_md5/4
        (postgrex) lib/postgrex/protocol.ex:504: Postgrex.Protocol.handshake/2
        (db_connection) lib/db_connection/connection.ex:135: DBConnection.Connection.connect/2
        (connection) lib/connection.ex:622: Connection.enter_connect/5
        (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

22:16:39.786 [error] GenServer #PID<0.490.0> terminating
** (RuntimeError) Connect raised a KeyError error. The exception details are hidden, as
they may contain sensitive data such as database credentials.

    (elixir) lib/keyword.ex:377: Keyword.fetch!/2
    (postgrex) lib/postgrex/protocol.ex:610: Postgrex.Protocol.auth_md5/4
    (postgrex) lib/postgrex/protocol.ex:504: Postgrex.Protocol.handshake/2
    (db_connection) lib/db_connection/connection.ex:135: DBConnection.Connection.connect/2
    (connection) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol

I reproduced the issue locally. On Ubuntu, the default authentication for a local user is via an md5 hashed password. One solution is to add a password for the postgres user:

sudo -u postgres psql

At the postgres=# prompt enter (including the backslash):

\password

and follow the new password and confirmation prompts. Enter \q and press return to exit psql.

At this point, you need to edit the apps/explorer/config/dev.secret.exs file and add the database configuration. It will look like this when you're done:

use Mix.Config

# Configure your database
config :explorer, Explorer.Repo,
  adapter: Ecto.Adapters.Postgres,
  database: "explorer_dev",
  hostname: "localhost",
  username: "postgres",
  password: "<REPLACE WITH THE PASSWORD YOU CHOSE>",
  loggers: [],
  pool_size: 20,
  pool_timeout: 60_000,
  timeout: 80_000

@nickjuntilla if you can test this locally, I'll work up a PR adding more detailed documentation to the README so that other Ubuntu users will have clearer instructions.

@tmecklem was able to run mix ecto.create now I'm getting this error:

[debug] Updating cached exchange rates
[error] `inotify-tools` is needed to run `file_system` for your system, check https://github.com/rvoicilas/inotify-tools/wiki for more information about how to install it. If it's already installed but not be found, appoint executable file with `config.exs` or `FILESYSTEM_FSINOTIFY_EXECUTABLE_FILE` env.
[warn] Could not start Phoenix live-reload because we cannot listen to the file system.
You don't need to worry! This is an optional feature used during development to
refresh your browser when you save files and it does not affect production.

[info] Running ExplorerWeb.Endpoint with Cowboy using http://0.0.0.0:4000
[error] Task #PID<0.762.0> started from Indexer.BlockFetcher terminating
** (Postgrex.Error) ERROR 53200 (out_of_memory): out of memory

Failed on request of size 100663296.
    (ecto) lib/ecto/adapters/sql.ex:431: Ecto.Adapters.SQL.execute_and_cache/7
    (ecto) lib/ecto/repo/queryable.ex:133: Ecto.Repo.Queryable.execute/5
    (ecto) lib/ecto/repo/queryable.ex:37: Ecto.Repo.Queryable.all/4
    (indexer) lib/indexer/block_fetcher.ex:250: Indexer.BlockFetcher.catchup_task/1
    (elixir) lib/task/supervised.ex:88: Task.Supervised.do_apply/2
    (elixir) lib/task/supervised.ex:38: Task.Supervised.reply/5
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Function: #Function<14.23623565/0 in Indexer.BlockFetcher.handle_info/2>
    Args: []

I'm gonna try installing inotify-tools

@tmecklem Ok I got it running! Is there anywhere I can see how to point it at my own custom network now?

@nickjuntilla Assuming you're deploying from a unix-based OS, you can set these values in your ~/.bashrc file.

export ETHEREUM_JSONRPC_VARIANT=parity
export ETHEREUM_JSONRPC_HTTP_URL=your_rpc_endpoint
The app will read these values every time it is run.

If you're not running a production environment you can change the RPC endpoint in apps/indexer/config/dev/parity.exs

@acravenho Is parity a style of endpoint? Is that what you guys use? What if I鈥檓 just using geth rpc do I just use the non-variant one? Should we use web sockets?

@nickjuntilla Parity is a client similar to Geth.

export ETHEREUM_JSONRPC_VARIANT=geth
export ETHEREUM_JSONRPC_HTTP_URL=your_rpc_endpoint

The app will read these values every time it is run.

If you're not running a production environment you can change the RPC endpoint in apps/indexer/config/dev/geth.exs

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dwalintukan picture dwalintukan  路  4Comments

dwalintukan picture dwalintukan  路  5Comments

KronicDeth picture KronicDeth  路  3Comments

vbaranov picture vbaranov  路  7Comments

hadv picture hadv  路  3Comments