fix: Sandbox owner checks in DB connection before exiting
The shared sandbox owner process exited without releasing its Postgrex connection, causing intermittent "client exited" error logs on CI. The owner now calls Sandbox.checkin before exiting, and on_exit waits for the owner to finish before switching to manual mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -47,7 +47,8 @@ defmodule Parrhesia.IntegrationCase do
|
|||||||
send(test_pid, {:sandbox_ready, self()})
|
send(test_pid, {:sandbox_ready, self()})
|
||||||
|
|
||||||
receive do
|
receive do
|
||||||
:stop -> :ok
|
:stop ->
|
||||||
|
Sandbox.checkin(Repo)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -60,8 +61,16 @@ defmodule Parrhesia.IntegrationCase do
|
|||||||
Sandbox.mode(Repo, {:shared, owner})
|
Sandbox.mode(Repo, {:shared, owner})
|
||||||
|
|
||||||
on_exit(fn ->
|
on_exit(fn ->
|
||||||
Sandbox.mode(Repo, :manual)
|
ref = Process.monitor(owner)
|
||||||
send(owner, :stop)
|
send(owner, :stop)
|
||||||
|
|
||||||
|
receive do
|
||||||
|
{:DOWN, ^ref, :process, ^owner, _reason} -> :ok
|
||||||
|
after
|
||||||
|
5_000 -> :ok
|
||||||
|
end
|
||||||
|
|
||||||
|
Sandbox.mode(Repo, :manual)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user