pierreabreup

pierreabreup

Erlang error: {:timeout, {:gen_server, :call, [#PID<0.7078.0>, {:checkout, #Reference<0.180397287.2702180353.191007>, true, 5000}, 5000]}}

I have a Phoenix project running on Docker Swarm using AWS spot machines and I’m getting this error when the service tries to start

(ErlangError) Erlang error: {:timeout, {:gen_server, :call, [#PID<0.7078.0>, {:checkout, #Reference<0.180397287.2702180353.191007>, true, 5000}, 5000]}}

This error sometimes happens, sometimes not, I didn’t figure out the pattern which triggers the error. Have you guys ever got this error?

I’m using Elixir 1.7.4 and Erlang 21

bash-4.4$ /opt/app/releases/1.0.0/content_proxy.sh remote_console
Erlang/OTP 21 [erts-10.1.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Interactive Elixir (1.7.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(content_proxy@127.0.0.1)1>

My O.S is Alpine Linux 3.8.4

My Application module only connect into MongoDB database

defmodule ContentProxy.Application do
  # See https://hexdocs.pm/elixir/Application.html
  # for more information on OTP Applications
  @moduledoc false

  use Application

  def start(_type, _args) do
    # List all child processes to be supervised
    database_config = Application.get_env(:content_proxy, :db_config)

    children = [
      ContentProxyWeb.Endpoint,
      %{
        id: Mongo,
        start: { Mongo, :start_link, [database_config] }
      }
    ]

    {:ok, _} = Logger.add_backend(Sentry.LoggerBackend)

    opts = [strategy: :one_for_one, name: ContentProxy.Supervisor]
    Supervisor.start_link(children, opts)
  end

  # Tell Phoenix to update the endpoint configuration
  # whenever the application is updated.
  def config_change(changed, _new, removed) do
    ContentProxyWeb.Endpoint.config_change(changed, removed)
    :ok
  end
end

Most Liked

pierreabreup

pierreabreup

mongo process is managed by Supervisor

def start(_type, _args) do
    # List all child processes to be supervised
    database_config = Application.get_env(:content_proxy, :db_config)

    children = [
      ContentProxyWeb.Endpoint,
      %{
        id: Mongo,
        start: { Mongo, :start_link, [database_config] }
      }
    ]

    {:ok, _} = Logger.add_backend(Sentry.LoggerBackend)

    opts = [strategy: :one_for_one, name: ContentProxy.Supervisor]
    Supervisor.start_link(children, opts)
  end

According to Supervisor doc Supervisor — Elixir v1.20.2, when Supervisor shutdown a child process, he waits until 5000 milliseconds before to kill it. This timeout is only for worker or infinity child spec.

an atom that defines how a child process should be terminated (see the "Shutdown values" section below). This key is optional and defaults to 5000 if the type is :worker or :infinity if the type is :supervisor.

Mongodb defines itself as a worker process (mongodb/lib/mongo.ex at master · elixir-mongo/mongodb · GitHub)

  @spec start_link(Keyword.t()) :: {:ok, pid} | {:error, Mongo.Error.t() | atom}
  def start_link(opts) do
    opts
    |> UrlParser.parse_url()
    |> Topology.start_link()
  end

  def child_spec(opts, child_opts \\ []) do
    Supervisor.Spec.worker(Mongo, [opts], child_opts)
  end

According to MongoDB source code (mongodb/lib/mongo.ex at master · elixir-mongo/mongodb · GitHub), he waits until 5000 for the initial connection, so I can’t say if the problem is when Supervisor tries to terminate mongodb process or when MongoDB process tries to connect the MongoDB host.

Ankhers

Ankhers

This has been something I have been trying to track down for a while now. Unfortunately I have never been able to replicate it. There is an issue open with a fair amount of traffic.

What version of the mongodb package are you currently using? You say that it sometimes happens and sometimes not. Can you say roughly how frequently it happens? Something like 20-30%. Would it be possible for me to gain access to your database to see if I am able to replicate the issue? If I can replicate it, there is a possibility I can track down what is happened and fix it.

Where Next?

Popular in Questions Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
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
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
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
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
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
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29603 241
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
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
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
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
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement