mcrunix

mcrunix

DBConnection Error(DBConnection.ConnectionError) tcp recv: closed (PGPool)

Hi Everyone, I’m trying to use PGPool in front of a PG database and Ecto’s using it but all commands failed. Here are the logs that I figured out.

$ mix ecto.create
** (Mix) The database for App.Repo couldn't be created: command timed out

Also, I hit PGPool through postgrex directly and more info turned out.

iex(1)> {:ok, pid} = Postgrex.start_link(hostname: "localhost", port: 7432, username: "postgres", password: "adminpassword", database: "postgres", prepare: :unnamed)
{:ok, #PID<0.594.0>}
iex(2)> Postgrex.query!(pid, "SELECT 1;", [], [timeout: 20000])
** (DBConnection.ConnectionError) tcp recv: closed (the connection was closed by the pool, possibly due to a timeout or because the pool has been terminated)
    (postgrex 0.15.7) lib/postgrex.ex:249: Postgrex.query!/4
{"msg":"Postgrex.Protocol (#PID<0.596.0>) disconnected: ** (DBConnection.ConnectionError) client #PID<0.592.0> timed out because it queued and checked out the connection for longer than 20000ms\n\n#PID<0.592.0> was at location:\n\n    :prim_inet.recv0/3\n    (postgrex 0.15.7) lib/postgrex/protocol.ex:2838: Postgrex.Protocol.msg_recv/4\n    (postgrex 0.15.7) lib/postgrex/protocol.ex:1241: Postgrex.Protocol.recv_parse/3\n    (postgrex 0.15.7) lib/postgrex/protocol.ex:1208: Postgrex.Protocol.recv_parse_describe/4\n    (postgrex 0.15.7) lib/postgrex/protocol.ex:1028: Postgrex.Protocol.parse_describe_flush/3\n    (db_connection 2.3.1) lib/db_connection/holder.ex:316: DBConnection.Holder.holder_apply/4\n    (db_connection 2.3.1) lib/db_connection.ex:1257: DBConnection.prepare/4\n    (db_connection 2.3.1) lib/db_connection.ex:1250: DBConnection.run_prepare/4\n    (db_connection 2.3.1) lib/db_connection.ex:1262: DBConnection.run_prepare_execute/5\n    (db_connection 2.3.1) lib/db_connection.ex:1359: DBConnection.run/6\n    (db_connection 2.3.1) lib/db_connection.ex:557: DBConnection.parsed_prepare_execute/5\n    (db_connection 2.3.1) lib/db_connection.ex:550: DBConnection.prepare_execute/4\n    (postgrex 0.15.7) lib/postgrex.ex:235: Postgrex.query_prepare_execute/4\n    (postgrex 0.15.7) lib/postgrex.ex:247: Postgrex.query!/4\n    (stdlib 3.14) erl_eval.erl:680: :erl_eval.do_apply/6\n    (elixir 1.11.3) src/elixir.erl:280: :elixir.recur_eval/3\n    (elixir 1.11.3) src/elixir.erl:265: :elixir.eval_forms/3\n    (iex 1.11.3) lib/iex/evaluator.ex:261: IEx.Evaluator.handle_eval/5\n    (iex 1.11.3) lib/iex/evaluator.ex:242: IEx.Evaluator.do_eval/3\n    (iex 1.11.3) lib/iex/evaluator.ex:220: IEx.Evaluator.eval/3\n","level":"error","datetime":"2021-02-24T17:16:11.000088Z","function":"disconnect/2","file":"lib/db_connection/connection.ex"}
iex(2)>

PGPool Logs:

2021-02-24 17:15:51: pid 166: LOG:  DB node id: 0 backend pid: 9337 statement: Parse: SELECT 1;
2021-02-24 17:15:51: pid 166: LOG:  DB node id: 0 backend pid: 9337 statement: D message
2021-02-24 17:16:11: pid 166: ERROR:  unable to read data from frontend
2021-02-24 17:16:11: pid 166: DETAIL:  EOF encountered with frontend

Ecto Config:

config :app, App.Repo,
  URL: databaseUrl,
  show_sensitive_data_on_connection_error: true,
  pool_size: 20,
  timeout: 60_000

My suspect is on the incompatibility DB Connection module with PSQL protocol, Should be noted I tried psql 11 and 13 versions, all had same issue.

did you experience same issue?

Most Liked

minhajuddin

minhajuddin

It looks like your elixir process initiated the FIN, packet 1066. Try connecting directly to the postgres database first and see if you can recreate it. Try using a library from another language e.g. pg gem from ruby to rule out any misconfigurations.

mcrunix

mcrunix

I’d like to put few other references which might be related.

Quote from Medium:

The migration was smooth, and the pgbouncer is the mandatory layer for the large scale Elixir deployment to handle the connections in a better way. We tried pgpool as well(to leverage the features like caching and the read/write split), but seems there is no official support from Elixir for pgpool. It gave some issues in our tests. So we went live with pgbouncer.

Where Next?

Popular in Questions Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
beno
I will often find my self writing things similar to: case some_value do nil -&gt; something() "" -&gt; something() _ -&gt; somethi...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43487 311
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
Lily
In templates/appointment/index.html.eex: &lt;%= for appointment &lt;- @appointments do %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= appoi...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement