rgkeith3

rgkeith3

Ecto per-query Timeouts not overriding config settings

I hope I’m not just missing some docs somewhere, but I can’t get Ecto.Adapters.SQL.query/4 to work the way I would expect it to work.

I’m trying to insert a column into a very big table and keep getting errors that the connection times out.
referencing this github issue I changed my migrations to:

Ecto.Adapters.SQL.query(Repo, “ALTER TABLE requests_table ADD fx_type_id integer;”, , timeout: :infinity)

Still, the migrations timeout at around 15 seconds, (the default timeout)

however I noticed, if I set the timeout in my config.exs to :infinity, the migrations actually work.

it seems to me that the timeout option passed into the query/4 should override the config settings for that query. in any case, is there a way to allow for long queries, without compromising my config settings?

Thanks, Grey

Most Liked

fishcakez

fishcakez

Ecto Core Team

A timeout is per transaction and not per query. A single query outside an explicit transaction is treated implicitly as a transaction so can have a timeout. Therefore any timeout passed to a query inside a transaction is ignored. A migration will use a transaction for postgresql by default, so the migration’s timeout is the timeout in affect and the query’s timeout is ignored. Changing the (global) configuration succeeds because that is being passed to the migration transaction. I think it makes sense to be able to pass the timeout manually however the migration is being run. If this is not available from the mix task we could definitely support it. Please open an issue and/or PR :slight_smile:.

PragTob

PragTob

Wow thanks totally missed this!

kodepett

kodepett

Just curious since I’ve been experiencing a bit of timeout in production. Will the below suffice.

Configuration file

config :debitor, Debitor.Repo,
url: database_url,
pool_size: String.to_integer(System.get_env(“POOL_SIZE”) || “10”)
timeout: 60000`

Repo call

Repo.all(query, [timeout: 120_000])

Thanks.

Where Next?

Popular in Questions Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
minhajuddin
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
nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
jaysoifer
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
pmjoe
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
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New

Other popular topics Top

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
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
vonH
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
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31142 143
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

We're in Beta

About us Mission Statement