0

开发 Elixir 应用程序。有一个 Scraper 函数通过 Postgrex 驱动程序将数据从 Google 电子表格复制到 postgres 数据库中。通过 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

我曾尝试15_000在源代码的任何地方更改 ms 超时设置,但似乎该设置已编译为二进制文件。我不是 erlang/elixir 开发人员,只是为了演示目的帮助客户安装应用程序。我的问题是:

  • 如何使用修改后的超时设置重新编译 Postgrex 驱动程序?
  • 是否有另一种方法可以覆盖此设置,或完全禁用超时?我已经尝试对源中“15”的每个实例进行查找替换。
4

2 回答 2

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

timeoutownership_timeout。这些值设置为 600 秒。可能它们中的任何一个都不是必需的。

我还想说,一旦我不得不从应用程序中删除所有内容_build并重新编译应用程序以实际应用这些值。

于 2018-10-13T04:18:35.463 回答
1

当使用 postgrex 发出查询时,最后一个参数可以是选项的关键字列表。

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

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

于 2018-10-12T16:22:38.150 回答