zacksiri
Async tests with Ecto Sandbox and GRPC
I’m having trouble enabling async: true in my tests that involved GRPC endpoints.
I get the following error:
10:46:17.210 [error] ** (DBConnection.OwnershipError) cannot find ownership process for #PID<0.6663.0>.
When using ownership, you must manage connections in one
of the four ways:
* By explicitly checking out a connection
* By explicitly allowing a spawned process
* By running the pool in shared mode
* By using :caller option with allowed process
The first two options require every new process to explicitly
check a connection out or be allowed by calling checkout or
allow respectively.
The third option requires a {:shared, pid} mode to be set.
If using shared mode in tests, make sure your tests are not
async.
The fourth option requires [caller: pid] to be used when
checking out a connection from the pool. The caller process
should already be allowed on a connection.
If you are reading this error, it means you have not done one
of the steps above or that the owner process has crashed.
See Ecto.Adapters.SQL.Sandbox docs for more information.
(ecto_sql 3.10.2) lib/ecto/adapters/sql.ex:1044: Ecto.Adapters.SQL.raise_sql_call_error/1
(ecto_sql 3.10.2) lib/ecto/adapters/sql.ex:945: Ecto.Adapters.SQL.execute/6
(ecto 3.10.3) lib/ecto/repo/queryable.ex:229: Ecto.Repo.Queryable.execute/4
(ecto 3.10.3) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3
(ecto 3.10.3) lib/ecto/repo/queryable.ex:151: Ecto.Repo.Queryable.one/3
(insterra 0.1.0) lib/insterra_grpc/servers/blueprint_server.ex:369: InsterraGRPC.BlueprintServer.update_component/2
(grpc 0.7.0) lib/grpc/server.ex:187: anonymous fn/6 in GRPC.Server.call_with_interceptors/4
(grpc 0.7.0) lib/grpc/telemetry.ex:94: anonymous fn/2 in GRPC.Telemetry.server_span/5
(telemetry 1.2.1) /Users/zacksiri/Development/_upmaru/insterra/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
(grpc 0.7.0) lib/grpc/telemetry.ex:93: GRPC.Telemetry.server_span/5
(grpc 0.7.0) lib/grpc/server/adapters/cowboy/handler.ex:376: GRPC.Server.Adapters.Cowboy.Handler.do_call_rpc/3
(grpc 0.7.0) lib/grpc/server/adapters/cowboy/handler.ex:349: GRPC.Server.Adapters.Cowboy.Handler.call_rpc/3
The app is just a phoenix app, and I have my own custom GRPC endpoint in the application.ex
If I just use Insterra.DataCase without async: true tests run without any issues. I’ve looked online to find examples of how people test their GRPC endpoint and couldn’t find any.
Here is how i setup my GPRC conn for tests
setup do
port = Enum.random(20000..20999)
{:ok, _server_pid} =
start_supervised(
{GRPC.Server.Supervisor, endpoint: InsterraGRPC.Endpoint, port: port, start_server: true},
[]
)
{:ok, conn} = GRPC.Stub.connect("localhost:#{port}")
{:ok, conn: conn}
end
Popular in Questions
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
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
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
Student & New to elixir. Nice language.
I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Hi all
I want to have a unix time, from the current time plus 1 hour.
DateTime.now + 1 hour
How to get it in elixir?
Thanks
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
Other popular topics
In Ruby, I can go:
User.find_by(email: "foobar@email.com").update(email: "hello@email.com")
How can I do something similar in Elixir? ...
New
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!)
This post collects co...
New
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
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
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







