sztosz

sztosz

Getting :emfile even thou ulimit is set and ERL_MAX_PORTS set to 65536

I have a poolboy pool of workers. What they do is when the worker GenServer is started it creates through erlport new python server. Then when worker is asked to do a job i takes an URL, download file, extract some data from it and, passes this data to python for parsing. But even though i have a ulimit -n set to 65536 and this in vm.args

## Node name
-name <%= Application.get_env(:morty, :node_name) %>

## Node cookie, used for distribution
-setcookie <%= Application.get_env(:morty, :cookie) %>

## Enable kernel poll
+K true
65536-env ERL_MAX_PORTS 

And I checked in fact with :erlang.system_info(:port_limit) to make sure that it returns 65536

I get constant errors like those below.

10:50:18.875 [error] Task #PID<0.6277.0> started from :"xxx_server" terminating
** (stop) exited in: :gen_server.call(:worker, {:checkout, #Reference<0.3831647178.621281284.180162>, true}, :infinity)
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: {:error, {:bad_return_value, {:error, {:emfile, [{:erlang, :open_port, [{:spawn, '/home/app/.virtualenvs/morty_python/bin/python -V'}, [{:line, 80}, :stderr_to_stdout, :hide]], []}, {:erlport_options, :get_version, 1, [file: '/app/deps/erlport/src/erlport_options.erl', line: 227]}, {:python_options, :check_python_version, 1, [file: '/app/deps/erlport/src/python_options.erl', line: 177]}, {:python_options, :find_python, 1, [file: '/app/deps/erlport/src/python_options.erl', line: 161]}, {:python_options, :get_python, 1, [file: '/app/deps/erlport/src/python_options.erl', line: 146]}, {:python_options, :parse, 2, [file: '/app/deps/erlport/src/python_options.erl', line: 88]}, {:python, :start, 3, [file: '/app/deps/erlport/src/python.erl', line: 168]}, {:gen_server, :init_it, 2, [file: 'gen_server.erl', line: 374]}]}}}}
            (poolboy) src/poolboy.erl:275: :poolboy.new_worker/1
            (poolboy) src/poolboy.erl:280: :poolboy.new_worker/2
            (poolboy) src/poolboy.erl:192: :poolboy.handle_call/3
            (stdlib) gen_server.erl:661: :gen_server.try_handle_call/4
            (stdlib) gen_server.erl:690: :gen_server.handle_msg/6
            (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
    :erlang.send(:worker, {:"$gen_cast", {:cancel_waiting, #Reference<0.3831647178.621281284.180162>}})
    (stdlib) gen_server.erl:445: :gen_server.do_send/2
    (stdlib) gen_server.erl:243: :gen_server.do_cast/2
    (poolboy) src/poolboy.erl:58: :poolboy.checkout/3
    (poolboy) src/poolboy.erl:74: :poolboy.transaction/3
    (elixir) lib/task/supervised.ex:89: Task.Supervised.do_apply/2
    (elixir) lib/task/supervised.ex:38: Task.Supervised.reply/5
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
10:50:19.768 [error] Task #PID<0.6361.0> started from :"yyy_server" terminating
** (stop) exited in: :gen_server.call(:worker, {:checkout, #Reference<0.3831647178.621281281.204659>, true}, :infinity)
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: {:error, {:bad_return_value, {:error, {:bad_return_value, {:error, {:open_port_error, :emfile}}}}}}
            (poolboy) src/poolboy.erl:275: :poolboy.new_worker/1
            (poolboy) src/poolboy.erl:296: :poolboy.prepopulate/3
            (poolboy) src/poolboy.erl:145: :poolboy.init/3
            (stdlib) gen_server.erl:374: :gen_server.init_it/2
            (stdlib) gen_server.erl:342: :gen_server.init_it/6
            (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
    (stdlib) gen_server.erl:223: :gen_server.call/3
    (poolboy) src/poolboy.erl:55: :poolboy.checkout/3
    (poolboy) src/poolboy.erl:74: :poolboy.transaction/3
    (elixir) lib/task/supervised.ex:89: Task.Supervised.do_apply/2
    (elixir) lib/task/supervised.ex:38: Task.Supervised.reply/5
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

And various ecto disconnection issues.

When I set poolboy config to this:
[{:name, {:local, :worker}}, {:worker_module, Morty.CrawlWorker}, {:size, 64}, {:max_overflow, 8}]

But if I change size to just 32 it starts to work OK, no more emfiles.

Where to look for the real cause of problem? :confused:

Where Next?

Popular in Questions Top

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
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
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
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
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 Postg...
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

Other popular topics Top

peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
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
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
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...
273 38985 115
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement