You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I managed to track down a situation where hackney_pool fills up if the response to POST is 307. I started seeing this in some APIs (SalesForce).
Try this example:
Save file below as server.exs and run elixir server.exs. It will make a POST 51 times until the last ones timeouts when waiting for the pool.
Mix.install[:cowboy,:plug,:plug_cowboy,:hackney]importLoggerdefmoduleServdoimportPlug.Conndefinit(o)dooenddefcall(conn,_o)doconn|>put_resp_content_type("text/plain")|>put_resp_header("Location","/some")|>send_resp(307,"OK")endend{:ok,pid}=Plug.Cowboy.httpServ,[],port: 5000info("Started server #{inspectpid}")Enum.each1..51,fn_->{:ok,307,_,_}=:hackney.request(:post,"http://localhost:5000",[],"",[pool: Pool])infoinspect:hackney_pool.get_statsPoolend
What I am seeing is:
$ elixir -v
Erlang/OTP 25 [erts-13.1.4] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]
Elixir 1.14.3 (compiled with Erlang/OTP 23)
$ elixir server.exs
14:01:12.211 [info] Started server #PID<0.293.0>
14:01:12.242 [info] [name: Pool, max: 50, in_use_count: 1, free_count: 0, queue_count: 0]
14:01:12.242 [info] [name: Pool, max: 50, in_use_count: 2, free_count: 0, queue_count: 0]
(.......)
14:01:12.265 [info] [name: Pool, max: 50, in_use_count: 49, free_count: 0, queue_count: 0]
14:01:12.266 [info] [name: Pool, max: 50, in_use_count: 50, free_count: 0, queue_count: 0]
** (MatchError) no match of right hand side value: {:error, :checkout_timeout}
server.exs:28: anonymous fn/1 in :elixir_compiler_0.__FILE__/1
(elixir 1.14.3) lib/enum.ex:980: anonymous fn/3 in Enum.each/2
(elixir 1.14.3) lib/enum.ex:4299: Enum.reduce_range/5
(elixir 1.14.3) lib/enum.ex:2472: Enum.each/2
Hope this helps tracking down these pesky connection pool bugs!
The text was updated successfully, but these errors were encountered:
marcinkoziej
changed the title
Pool connection not freed when response code is 307
Pool connection not freed when response code is 307 (with example! :tada)
Mar 29, 2023
marcinkoziej
changed the title
Pool connection not freed when response code is 307 (with example! :tada)
Pool connection not freed when response code is 307 (with example! 🎉 )
Mar 29, 2023
Hi!
I managed to track down a situation where
hackney_pool
fills up if the response to POST is 307. I started seeing this in some APIs (SalesForce).Try this example:
Save file below as server.exs and run
elixir server.exs
. It will make a POST 51 times until the last ones timeouts when waiting for the pool.What I am seeing is:
Hope this helps tracking down these pesky connection pool bugs!
The text was updated successfully, but these errors were encountered: