baruh
Getting timeout on running Ecto.Migrator.with_repo/2
I want to run a task separate from my main application with connection to the database.
The task looks something like
defmodule MyService.Task do
def call do
Application.load(:my_service)
{:ok, _, _} = Ecto.Migrator.with_repo(MyService.Repo, fn repo ->
do_some_work(repo)
end)
end
end
In do_some_work(repo) I simply schedule some jobs using Oban.
I am running it with eval
bin/my_service eval "MyService.Task.call()"
However it times out after 15s.
Postgrex.Protocol (#PID<0.274.0>) disconnected: ** (DBConnection.ConnectionError) client #PID<0.165.0> timed out because it queued and checked out the
main ** (DBConnection.ConnectionError) connection is closed because of an error, disconnect or timeout
main (ecto_sql 3.8.3) lib/ecto/adapters/sql.ex:932: Ecto.Adapters.SQL.raise_sql_call_error/1
main (ecto 3.8.4) lib/ecto/repo/schema.ex:744: Ecto.Repo.Schema.apply/4 main (ecto 3.8.4) lib/ecto/repo/schema.ex:367: anonymous fn/15 in Ecto.Repo.Schema.do_insert/4
main (ecto_sql 3.8.3) lib/ecto/adapters/sql.ex:1222: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4 main (db_connection 2.4.2) lib/db_connection.ex:865: DBConnection.transaction/3 main (oban 2.12.1) lib/oban/queue/basic_engine.ex:53: Oban.Queue.BasicEngine.insert_job/2 main (oban 2.12.1) lib/oban/queue/engine.ex:234: anonymous fn/3 in Oban.Queue.Engine.with_span/4
Is there a way to configure the timeout for the migrator?
Something like
Ecto.Migrator.with_repo(MyService.Repo, fn repo ->
do_some_work(repo)
end, timeout: 1200_000)
or probably change the Repo config like
Application.load(:my_service)
config = Application.get_env(:my_service, MyService.Repo) |> Keyword.put(:timeout, 1200_000)
Application.put_env(:my_service, MyService.Repo, config)
Ecto.Migrator.with_repo(MyService.Repo, fn repo ->
do_some_work(repo)
end)
Marked As Solved
baruh
I end up simply increasing the timeout in my MyService.Repo config
config :my_service, MyService.Repo,
url: "....",
pool_size: 10,
timeout: 1_200_000 # 20 mins
0
Popular in Questions
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
I have an umbrella app.
Some of the apps inside depend on other apps in the umbrella, unsurprisingly.
I’m writing a test for one of the...
New
can someone please explain to me how Enum.reduce works with maps
New
For example for a current url like
http://localhost:4000/cosmetic/products?_utf8=✓&query=perfume&page=2,
I would like to get:
...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Hi all,
I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I’m trying to use Postgres...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
I have a super simple question about elixir - how would I take a file like this
foo
bar
baz
and output a new file that enumerates th...
New
I would like to know what is the best IDE for elixir development?
New
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
Other popular topics
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
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set?
Thanks.
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
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
Lets say I have map like this fetching from my database
%{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)?
Would
mix ecto.rollback -v 200809061...
New
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









