0

Working on an Elixir app. There's a Scraper function that copies data from a Google Spreadsheet into a postgres database via the Postgrex driver. The connection through the Google API works fine, but the function always times out after 15 seconds.

01:48:36.654 [info] Running MyApp.Endpoint with Cowboy using http://localhost:80
Interactive Elixir (1.6.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Scraper.update
542
iex(2)> 01:48:55.889 [error] Postgrex.Protocol (#PID<0.324.0>) disconnected: ** (DBConnection.ConnectionError) owner #PID<0.445.0> timed out because it owned the connection for longer than 15000ms

I have tried changing the 15_000 ms timeout setting everywhere in the source, but it seems the setting has been compiled into binary. I am not an erlang/elixir developer, just helping a client install the app for the purposes of demoing. My question is:

  • How can I recompile the Postgrex driver with the modified timeout setting?
  • Is there another way to override this setting, or disable the timeout altogether? I have tried find-replace of basically every instance of "15" in the source.
ted.strauss
  • 4,119
  • 4
  • 34
  • 57

2 Answers2

1

When issuing a query with postgrex, the last argument can be a keyword list of options.

Postgrex.query!(pid, "AN SQL STATEMENT;", [], timeout: 50_000, pool_timeout: 40_000)

https://hexdocs.pm/postgrex/Postgrex.html#query/4

m3characters
  • 2,240
  • 2
  • 14
  • 18
  • I have added those arguments but getting the same error. Seems that I need to recompile the postgrex module, or whatever is the elixir/erlang equivalent of rebuilding the app. – ted.strauss Oct 15 '18 at 13:37
1
config :my_app, MyApp.Repo,
  adapter: Ecto.Adapters.Postgres,
  username: "postgres",
  password: "postgres",
  database: "my_app_dev",
  hostname: "localhost",
  timeout: 600_000,
  ownership_timeout: 600_000,
  pool_timeout: 600_000

Look at timeout and ownership_timeout. These values are set to 600 seconds. And probably not of them are necessary.

Also I want to say that once I had to remove everything from _build and recompile an application to have this values actually applied.

denis.peplin
  • 9,585
  • 3
  • 48
  • 55
  • I have added those arguments but getting the same error. Seems that I need to recompile the postgrex module, or whatever is the elixir/erlang equivalent of rebuilding the app. – ted.strauss Oct 15 '18 at 13:37