sahilpaudel

sahilpaudel

(DBConnection.ConnectionError) tcp recv: closed (the connection was closed by the pool, possibly due to a timeout or because the pool has been terminated)

Stack trace
DBConnection.ConnectionError: (DBConnection.ConnectionError) tcp recv: closed (the connection was closed by the pool, possibly due to a timeout or because the pool has been terminated)
(ecto_sql) lib/ecto/adapters/sql.ex:612: Ecto.Adapters.SQL.raise_sql_call_error/1
(ecto_sql) lib/ecto/adapters/sql.ex:545: Ecto.Adapters.SQL.execute/5
(ecto) lib/ecto/repo/queryable.ex:192: Ecto.Repo.Queryable.execute/4
(ecto) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
(diamond) lib/diamond/concepts/experiment/update_count_for_each_running_experiment.ex:21: Diamond.Concepts.Experiment.UpdateCountForEachRunningExperiment.fetch_count/1
(diamond) lib/diamond/concepts/experiment/update_count_for_each_running_experiment.ex:10: Diamond.Concepts.Experiment.UpdateCountForEachRunningExperiment.call/0
(quantum) lib/quantum/executor.ex:141: anonymous fn/2 in Quantum.Executor.run/4
(elixir) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
(quantum) anonymous fn() in Quantum.Executor.run/4

config.exs

config :diamond, Diamond.Scheduler,
  jobs: [
    {"*/60 * * * *", {Diamond.Concepts.Experiment.UpdateCountForEachRunningExperiment, :call, []}}
  ]

Also sometimes I get

15:00:15.060 [error] Postgrex.Protocol (#PID<0.2309.0>) disconnected: ** (DBConnection.ConnectionError) client #PID<0.28048.4> timed out because it queued and checked out the connection for longer than 15000ms

#PID<0.28048.4> was at location:

    :prim_inet.recv0/3
    (postgrex) lib/postgrex/protocol.ex:2837: Postgrex.Protocol.msg_recv/4
    (postgrex) lib/postgrex/protocol.ex:1879: Postgrex.Protocol.recv_bind/3
    (postgrex) lib/postgrex/protocol.ex:1771: Postgrex.Protocol.bind_execute/4
    (db_connection) lib/db_connection/holder.ex:316: DBConnection.Holder.holder_apply/4
    (db_connection) lib/db_connection.ex:1255: DBConnection.run_execute/5
    (db_connection) lib/db_connection.ex:1342: DBConnection.run/6
    (db_connection) lib/db_connection.ex:539: DBConnection.parsed_prepare_execute/5

I have been getting this error in production sicen ages and I have increase the time in cron still it didn’t help.
Can anyone please help me here.

Thanks

Marked As Solved

al2o3cr

al2o3cr

There is not. You’ll want an index covering experiment_split_log.experiment_id, otherwise the only way Postgres can find rows satisfying this query is by checking each of the 279 million…

from(esl in Diamond.Models.ExperimentSplitLog,
      where: esl.experiment_id in ^experiment_ids,

Also Liked

al2o3cr

al2o3cr

This error usually happens when a query takes too long to execute on the database side. If you post the code of UpdateCountForEachRunningExperiment.fetch_count/1 and relevant schemas, folks will be able to help spot obvious performance traps.

al2o3cr

al2o3cr

A foreign key constraint requires an index / primary key on the referenced column (id in the experiments table) but does NOT create or require an index on the referring column (experiment_id).

Sequential-scanning 279 million rows without an index? You’re Gonna Have A Bad Time.

Where Next?

Popular in Questions Top

myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
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
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
JulienCorb
I am trying to implement my new.html.eex file to create new posts on my website. new.html.eex: &lt;h1&gt;Create Post&lt;/h1&gt; &lt;%= ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
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

Other popular topics Top

johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31194 112
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42158 114
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
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement