besteman

besteman

Ecto_SQL checkout error

Hey!

My team and I are migrating away from Mariaex and Ecto 2 to Ecto 3 and myxql.

We have all the main changes done and everything is working as it should except for one thing, the prepare statement.

Our config.ex looks like this:

use Mix.Config

# Needed for ecto tasks that modify the db like migrate
# Since we'll never directly modify the replica db it doesn't need to be in here
config :db, ecto_repos: [Db.Repo]

config :db, :read_repo, Db.ReadOnlyRepo

config :db, Db.Repo,
  priv: "priv/repo",
  pool_size: 10,
  connect_timeout: 25000,
  loggers: [{ExJsonLogger.Ecto.Logger, :log, []}],
  prepare: :unnamed

config :db, Db.ReadOnlyRepo,
  priv: "priv/repo",
  pool_size: 10,
  connect_timeout: 25000,
  loggers: [{ExJsonLogger.Ecto.Logger, :log, []}],
  prepare: :unnamed

When I run the test we have, we get the following error:

** (EXIT from #PID<0.93.0>) an exception was raised:
    ** (DBConnection.ConnectionError) could not checkout the connection owned by #PID<0.93.0>. When using the sandbox, connections are shared, so this may imply another process is using a connection. Reason: connection not available and request was dropped from queue after 123ms. You can configure how long requests wait in the queue using :queue_target and :queue_interval. See DBConnection.start_link/2 for more information
        (ecto_sql) lib/ecto/adapters/sql.ex:751: Ecto.Adapters.SQL.raise_sql_call_error/1
        (ecto_sql) lib/ecto/adapters/sql.ex:684: Ecto.Adapters.SQL.execute/5
        (ecto) lib/ecto/repo/queryable.ex:229: Ecto.Repo.Queryable.execute/4
        (ecto) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
        (ecto) lib/ecto/repo/preloader.ex:229: Ecto.Repo.Preloader.fetch_query/8
        (elixir) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
        (elixir) lib/task/supervised.ex:35: Task.Supervised.reply/5
        (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

When I remove the prepared statement in the config, everything works and passes.

I have checked the docs and we are doing shared mode like this:

  setup tags do


    :ok = Ecto.Adapters.SQL.Sandbox.checkout(Db.Repo)

    unless tags[:async] do
      Ecto.Adapters.SQL.Sandbox.mode(Db.Repo, {:shared, self()})
    end
end

Any ideas?

First Post!

bolducp

bolducp

Hi there! Did you ever figure out a fix here?

Where Next?

Popular in Questions Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
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
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
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
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New
9mm
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
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
Harrisonl
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
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
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement