简体   繁体   English

如何覆盖或禁用Postgrex超时设置:15秒?

[英]How to override or disable Postgrex timeout setting: 15 seconds?

Working on an Elixir app. 在Elixir应用程序上工作。 There's a Scraper function that copies data from a Google Spreadsheet into a postgres database via the Postgrex driver. 有一个Scraper函数,可通过Postgrex驱动程序将数据从Google Spreadsheet复制到postgres数据库。 The connection through the Google API works fine, but the function always times out after 15 seconds. 通过Google API的连接工作正常,但该功能始终在15秒后超时。

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. 我尝试在源代码中的任何地方更改15_000 ms超时设置,但似乎该设置已编译为二进制。 I am not an erlang/elixir developer, just helping a client install the app for the purposes of demoing. 我不是erlang / elixir开发人员,只是帮助客户安装应用程序以进行演示。 My question is: 我的问题是:

  • How can I recompile the Postgrex driver with the modified timeout setting? 我怎样才能重新编译修改后的超时设置的Postgrex驱动程序?
  • 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. 我试图找到替换基本上每源“15”的实例。

When issuing a query with postgrex, the last argument can be a keyword list of options. 使用postgrex发出查询时,最后一个参数可以是选项的关键字列表。

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

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

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 . 查看timeoutownership_timeout These values are set to 600 seconds. 这些值设置为600秒。 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. 我还要说的是,一旦我不得不从_build删除所有_build并重新编译应用程序以实际应用此值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM