Zachareee

Zachareee

Ash.Postgres timeout

Hi, I’m working with a Postgres database which tends to take really long to retrieve data, it’s a simple :read action with a filter. There are no optimisations to the database that can be done on my side and so I’m looking to increase the timeout when querying the AshPostgres.Repo to avoid this error:

Postgrex.Protocol (#PID<0.359.0>) disconnected: ** (DBConnection.ConnectionError) client #PID<0.739.0> timed out because it queued and checked out the connection for longer than 15000ms

I have tried setting timeout to :infinity in config/dev.exs as so:

config :hachiware, Hachiware.Reports.Repo,
  hostname: "hachiware-db",
  username: "postgres",
  password: "postgres",
  database: "postgres",
  port: 5432,
  show_sensitive_data_on_connection_error: true,
  pool_size: 10,
  timeout: :infinity

On the repo:

  use AshPostgres.Repo, otp_app: :hachiware, timeout: :infinity

On the domain:

execution do
  timeout :infinity
end

As well as on the Ash.read! action:

__MODULE__
|> Ash.read!(timeout: :infinity)

However it feels that nothing I’m doing works at all, any advice and help is appreciated!

Marked As Solved

zachdaniel

zachdaniel

Creator of Ash

Hmm…okay, maybe just faulty memory on my part. Seems strange that you’d be seeing this behavior :thinking: The default is 15000, and that’s the error you’re getting so it seems like it’s just somehow not being set? Setting timeout to infinity should AFAIK remove any kind of Postgrex timeout like that. Might be worth checking some base assumptions. Do you have multiple repos? Is this issue happening in production, implying a need to set this config in prod.exs (or runtime.exs) as well? If nothing there helps, perhaps you could put together a reproduction and open an issue?

Last Post!

Zachareee

Zachareee

Hi sflr, I realised I put the timeout on the wrong repo (yes I’m working on multiple repos), thank you for the help!

Where Next?

Popular in Questions Top

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a &gt; b) do {:ok, "a"} end if (a &lt; b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
greenz1
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
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
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
greenz1
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
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44532 311
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
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New

We're in Beta

About us Mission Statement