Distillery build not connecting with postgresql elixir phoenix

430 Views Asked by At

I switched from exrm to distillery in build release for my phoenix project. Everything is working fine. when I do

iex -S mix phx.server

Application runs and everything gets connected with DB. but the build release not connecting with the database. (I think doing above command apart from build its getting dev values for db.)

2018-08-10 08:59:19.160 [error] Postgrex.Protocol (#PID<0.2803.0>) failed to connect: ** (Postgrex.Error) FATAL 53300 (too_many_connections): remaining connection slots are reserved for non-replication superuser connections

when I see /opt/evercam_media/releases/1.0.1/sys.config file it gives me the right values of Database which put there for DB connection

       {mode,prod}]},
  {'Elixir.EvercamMedia.Repo',
      [{adapter,'Elixir.Ecto.Adapters.Postgres'},
       {types,'Elixir.EvercamMedia.PostgresTypes'},
       {url,<<"postgres://localhost/evercam_dev">>},
       {socket_options,[{keepalive,true}]},
       {timeout,60000},
       {pool_timeout,60000},
       {pool_size,80},
       {lazy,false},
       {ssl,true}]},
  {'Elixir.EvercamMedia.SnapshotRepo',
      [{adapter,'Elixir.Ecto.Adapters.Postgres'},
       {url,<<"postgres://localhost/evercam_dev">>},
       {socket_options,[{keepalive,true}]},
       {timeout,60000},
       {pool_timeout,60000},
       {pool_size,100},
       {lazy,false},
       {ssl,true}]}]}].

what is the issue here? It's not getting connected with the database, what I am doing wrong?

1

There are 1 best solutions below

0
On BEST ANSWER

The cause of this is your application has two repos, both using not lazy connection pools, of a total size of 180.

The default setting for PostgreSQL is 100 concurrent client connections.

You have two options:

increase max_connections setting in postgresql.conf to, say, 200

max_connections = 200
shared_buffers = 50MB

decrease ecto connection pools

config :ymy_app, EvercamMedia.Repo,
  adapter: Ecto.Adapters.Postgres,
  ...
  pool_size: 40

This answer might be useful as well.