Switch to killing during chunking

This commit is contained in:
Mark Felder 2024-06-04 16:16:57 -04:00
parent 92d3206f12
commit 7302a8f76d
3 changed files with 3 additions and 4 deletions

View file

@ -1,7 +1,6 @@
defmodule Pleroma.Chaos do
def kill_random_worker(pid) do
with true <- :sys.get_state(pid).pool in [:media, :rich_media],
true <- Enum.random(0..10) >= 5 do
with true <- Enum.random(0..100) >= 75 do
Process.exit(pid, :kill)
end
end

View file

@ -30,8 +30,7 @@ defmodule Pleroma.Gun.ConnectionPool.WorkerSupervisor do
start_worker(opts, true)
end
{:ok, pid} = res ->
Task.start(fn -> Pleroma.Chaos.kill_random_worker(pid) end)
res ->
res
end
end

View file

@ -220,6 +220,7 @@ defmodule Pleroma.ReverseProxy do
Keyword.get(opts, :max_body_length, @max_body_length)
),
{:ok, conn} <- chunk(conn, data) do
Pleroma.Chaos.kill_random_worker(self())
chunk_reply(conn, client, opts, sent_so_far, duration)
else
:done -> {:ok, conn}