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

First Post! Switch mode

PragTob

PragTob

Hi there,

Iirc the timeout option is passed to the Repo call when you hand it the query not the the query itself.

See the docs: Ecto.Repo — Ecto v3.14.0

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?

Trending in Questions Top

jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
saveman71
Hello ! We want new/edit form pages to POST/PUT to their own URL rather than the resources REST defaults (post /things, put /things/:id)...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement