Skip to content

Instantly share code, notes, and snippets.

@paulfioravanti
Last active February 16, 2018 01:46
Show Gist options
  • Save paulfioravanti/94c81bb5f7880f6a949a1beaa9159427 to your computer and use it in GitHub Desktop.
Save paulfioravanti/94c81bb5f7880f6a949a1beaa9159427 to your computer and use it in GitHub Desktop.
Attempted Heroku deploy of Elixir Phoenix Application

Set up new app for Elixir and Phoenix as per Phoenix Heroku Guide

➜ [phoenix_and_elm (master)]$ heroku create --buildpack "https://github.com/HashNuke/heroku-buildpack-elixir"
Creating app... done, ⬢ evening-bastion-24140
Setting buildpack to https://github.com/HashNuke/heroku-buildpack-elixir... done
https://evening-bastion-24140.herokuapp.com/ | https://git.heroku.com/evening-bastion-24140.git
➜ [phoenix_and_elm (master)]$ heroku buildpacks:add https://github.com/gjaldon/heroku-buildpack-phoenix-static --app evening-bastion-24140
Buildpack added. Next release on evening-bastion-24140 will use:
  1. https://github.com/HashNuke/heroku-buildpack-elixir
  2. https://github.com/gjaldon/heroku-buildpack-phoenix-static
Run git push heroku master to create a new release using these buildpacks.
➜ [phoenix_and_elm (master)]$ heroku addons:create heroku-postgresql:hobby-dev --app evening-bastion-24140
Creating heroku-postgresql:hobby-dev on ⬢ evening-bastion-24140... free
Database has been created and is available
 ! This database is empty. If upgrading, you can transfer
 ! data from another database with pg:copy
Created postgresql-horizontal-39388 as DATABASE_URL
Use heroku addons:docs heroku-postgresql to view documentation
➜ [phoenix_and_elm (master)]$ heroku config:set POOL_SIZE=18 --app evening-bastion-24140
Setting POOL_SIZE and restarting ⬢ evening-bastion-24140... done, v4
POOL_SIZE: 18
➜ [phoenix_and_elm (master)]$ mix phx.gen.secret
ZIOYsFzD0SvEa+r+MmEzvnZaDQL3YraVzOMC7WXHIXazpZYIyxi/UbSllkc1/4ky
➜ [phoenix_and_elm (master)]$ heroku config:set SECRET_KEY_BASE="ZIOYsFzD0SvEa+r+MmEzvnZaDQL3YraVzOMC7WXHIXazpZYIyxi/UbSllkc1/4ky" --app evening-bastion-24140
Setting SECRET_KEY_BASE and restarting ⬢ evening-bastion-24140... done, v5
SECRET_KEY_BASE: ZIOYsFzD0SvEa+r+MmEzvnZaDQL3YraVzOMC7WXHIXazpZYIyxi/UbSllkc1/4ky
➜ [phoenix_and_elm (master)]$ git push heroku master
remote: -----> Finalizing build
remote:        Caching versions for future builds
remote:        Creating runtime environment
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing...
remote:        Done: 98.6M
remote: -----> Launching...
remote:        Released v6
remote:        https://evening-bastion-24140.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/evening-bastion-24140.git

Application deploys fine, but, when I try and migrate the database, I get the following error:

➜ [phoenix_and_elm (master)]$ heroku run "POOL_SIZE=2 mix do ecto.migrate" --app evening-bastion-24140
Running POOL_SIZE=2 mix do ecto.migrate on ⬢ evening-bastion-24140... up, run.4068 (Free)
22:18:35.398 [error] GenServer #PID<0.210.0> terminating
** (RuntimeError) Connect raised a ArgumentError error. The exception details are hidden, as
they may contain sensitive data such as database credentials.

    (postgrex) lib/postgrex/utils.ex:67: anonymous fn/1 in Postgrex.Utils.parse_version/1
    (elixir) lib/enum.ex:1294: Enum."-map/2-lists^map/1-0-"/2
    (elixir) lib/enum.ex:1294: Enum."-map/2-lists^map/1-0-"/2
    (postgrex) lib/postgrex/utils.ex:67: Postgrex.Utils.parse_version/1
    (postgrex) lib/postgrex/protocol.ex:663: Postgrex.Protocol.bootstrap_send/6
    (postgrex) lib/postgrex/protocol.ex:497: 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
Last message: nil
22:18:35.399 [error] GenServer #PID<0.218.0> terminating
** (RuntimeError) Connect raised a ArgumentError error. The exception details are hidden, as
they may contain sensitive data such as database credentials.

    (postgrex) lib/postgrex/utils.ex:67: anonymous fn/1 in Postgrex.Utils.parse_version/1
    (elixir) lib/enum.ex:1294: Enum."-map/2-lists^map/1-0-"/2
    (elixir) lib/enum.ex:1294: Enum."-map/2-lists^map/1-0-"/2
    (postgrex) lib/postgrex/utils.ex:67: Postgrex.Utils.parse_version/1
    (postgrex) lib/postgrex/protocol.ex:663: Postgrex.Protocol.bootstrap_send/6
    (postgrex) lib/postgrex/protocol.ex:497: 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
Last message: nil
** (exit) exited in: :gen_server.call(#PID<0.210.0>, {:checkout, #Reference<0.3162784634.3730046983.76395>, true, :infinity}, 5000)
    ** (EXIT) an exception was raised:
        ** (RuntimeError) Connect raised a ArgumentError error. The exception details are hidden, as
they may contain sensitive data such as database credentials.

            (postgrex) lib/postgrex/utils.ex:67: anonymous fn/1 in Postgrex.Utils.parse_version/1
            (elixir) lib/enum.ex:1294: Enum."-map/2-lists^map/1-0-"/2
            (elixir) lib/enum.ex:1294: Enum."-map/2-lists^map/1-0-"/2
            (postgrex) lib/postgrex/utils.ex:67: Postgrex.Utils.parse_version/1
            (postgrex) lib/postgrex/protocol.ex:663: Postgrex.Protocol.bootstrap_send/6
            (postgrex) lib/postgrex/protocol.ex:497: 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
    (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:1141: DBConnection.run_meter/3
    (db_connection) lib/db_connection.ex:592: DBConnection.prepare_execute/4
    (ecto) lib/ecto/adapters/postgres/connection.ex:86: Ecto.Adapters.Postgres.Connection.execute/4
    (ecto) lib/ecto/adapters/sql.ex:256: Ecto.Adapters.SQL.sql_call/6
    (ecto) lib/ecto/adapters/sql.ex:198: Ecto.Adapters.SQL.query!/5

Similarly, if I try and open up a console, then I get a similar error:

➜ [phoenix_and_elm (master)]$ heroku run "POOL_SIZE=1 iex -S mix" --app evening-bastion-24140
Running POOL_SIZE=1 iex -S mix on ⬢ evening-bastion-24140... up, run.3937 (Free)
Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false]

Interactive Elixir (1.6.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> 00:08:45.629 [error] GenServer #PID<0.249.0> terminating
** (RuntimeError) Connect raised a ArgumentError error. The exception details are hidden, as
they may contain sensitive data such as database credentials.

    (postgrex) lib/postgrex/utils.ex:67: anonymous fn/1 in Postgrex.Utils.parse_version/1
    (elixir) lib/enum.ex:1294: Enum."-map/2-lists^map/1-0-"/2
    (elixir) lib/enum.ex:1294: Enum."-map/2-lists^map/1-0-"/2
    (postgrex) lib/postgrex/utils.ex:67: Postgrex.Utils.parse_version/1
    (postgrex) lib/postgrex/protocol.ex:663: Postgrex.Protocol.bootstrap_send/6
    (postgrex) lib/postgrex/protocol.ex:497: 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
Last message: nil
00:08:45.653 [error] GenServer #PID<0.268.0> terminating
** (RuntimeError) Connect raised a ArgumentError error. The exception details are hidden, as
they may contain sensitive data such as database credentials.

    (postgrex) lib/postgrex/utils.ex:67: anonymous fn/1 in Postgrex.Utils.parse_version/1
    (elixir) lib/enum.ex:1294: Enum."-map/2-lists^map/1-0-"/2
    (elixir) lib/enum.ex:1294: Enum."-map/2-lists^map/1-0-"/2
    (postgrex) lib/postgrex/utils.ex:67: Postgrex.Utils.parse_version/1
    (postgrex) lib/postgrex/protocol.ex:663: Postgrex.Protocol.bootstrap_send/6
    (postgrex) lib/postgrex/protocol.ex:497: 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
Last message: nil
  • This application works as expected in development.
  • This app has been deployed successfully on Heroku in the past, so I'm not sure what has happened to make it stop working like this.
  • I've tried heroku pg:reset DATABASE_URL commands to reset the database, but that hasn't seemed to work.
  • I attempted to deploy a brand new unrelated application to Heroku with the same buildpack/config setup, and migrations worked fine, so this would seem to mean that the problem is localised to this application.
  • I attempted to create other Heroku apps and deploy this application to them, but the same failure occurs.

What could be responsible for this error?

Update

This issue ended up being a bug in Postgrex. Upgrading the Postgrex package solved the issue. Details in elixir-ecto/postgrex#370

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment