【问题标题】:Firebase functions raises TimeoutError while connecting to Google Cloud SqlFirebase 函数在连接到 Google Cloud Sql 时引发 TimeoutError
【发布时间】:2019-05-22 13:08:45
【问题描述】:

我的 firebase 函数会打开一个 sql 事务并执行一系列插入操作。虽然该功能在我的本地和 CI 系统中有效,但在连接到 Google SQL Postgres 时它不起作用

我收到超时错误。以下是日志。有什么想法吗?

5:02:29.925 pm myApp Function execution took 20280 ms, finished with status code: 500
5:02:29.915 pm myApp TimeoutError: ResourceRequest timed out
    at ResourceRequest._fireTimeout (/user_code/node_modules/sequelize/node_modules/generic-pool/lib/ResourceRequest.js:62:17)
    at Timeout.bound (/user_code/node_modules/sequelize/node_modules/generic-pool/lib/ResourceRequest.js:8:15)
    at ontimeout (timers.js:386:11)
    at tryOnTimeout (timers.js:250:5)
    at Timer.listOnTimeout (timers.js:214:5)
5:02:29.914 pm myApp Error Express : ResourceRequest timed out
5:02:29.911 pm myApp Executing (1963639b-91e6-42c9-acdf-8cb6463d5150): ROLLBACK;
5:02:09.904 pm myApp Executing (1963639b-91e6-42c9-acdf-8cb6463d5150): INSERT INTO ...... RETURNING *;
5:02:09.893 pm myApp Executing (1963639b-91e6-42c9-acdf-8cb6463d5150): START TRANSACTION;

【问题讨论】:

  • 请编辑您的问题以显示您正在使用的代码。没有这个,就只有猜测了。

标签: postgresql google-cloud-functions google-cloud-sql


【解决方案1】:

经过一番搜索找到它。在生产中,我使用的池大小为“1”(推荐用于 firebase 功能)。在 sequelize 事务中,我几乎没有执行事务的选择查询。因此,非事务查询需要单独的连接。 Tran 查询等待 non-tran 完成。但是 non-tran 无法继续,因为它需要一个由 tran 查询保持的连接。因此它超时了。

最好在这里解释。 https://github.com/sequelize/sequelize/issues/7884#issuecomment-338778283

将选择查询更正为同一事务的一部分后,问题解决了。

【讨论】:

  • 你能分享你用来从 firebase 连接到 google 的代码吗?我正在度过一段糟糕的时光,找到了一些有用的东西。
  • @1252748 在stackoverflow.com/questions/59537323/…留下了评论
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-03-27
  • 2020-01-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多