来自Lambda的Tedious的ETIMEOUT

时间:2020-08-25 17:54:14

标签: amazon-web-services aws-lambda amazon-rds tedious

设置

  • AWS Lambda( 3秒超时
  • NodeJS 12.x
  • mssql 2.6.1
  • tediousmssql的依赖性,因此安装了乏味的6.7.0)
  • RDS中的SQL Server数据库(db.t3.small)

我还处理着相当多的流量,每分钟大约有1000次调用。

问题

大多数情况下,Lambda执行得很好。 Lambda抛出错误的时间大约为0.35%。日志如下所示:

CloudWatchLogs

在屏幕快照中,您可以看到该功能启动,打印一些调试信息,然后引发错误,结束和报告。

这是一个“超时”错误,但错误消息显示为

RequestError:超时:请求未能在15000ms内完成

这使我感到困惑,因为您在REPORT日志中看到的,调用时间总计仅为255.33ms。

问题

一个明显的问题是在15秒内仅255毫秒后超时如何发生?这是tediousmssql,我的代码或其他问题吗?如果我的代码与问题有关,请告诉我,然后我可以添加它。我认为代码基本上是可以正常工作的,因为它在99%的时间内都能正常工作。

失败的理论:

  • 日志是交错的,并且错误不是来自225ms的调用。这是错误的,因为在屏幕截图中,请求ID匹配。
  • 连接到数据库时出现间歇性错误,可能是DNS问题。解决数据库主机时,我见过非常罕见的EAIAGAIN DNS错误,但这似乎与该错误的稳定性不符。
  • 在Tedious的GitHub问题中,我没有发现任何超级有用的东西。

完全错误

{
    "errorType": "Runtime.UnhandledPromiseRejection",
    "errorMessage": "RequestError: Timeout: Request failed to complete in 15000ms",
    "reason": {
        "errorType": "RequestError",
        "errorMessage": "Timeout: Request failed to complete in 15000ms",
        "code": "ETIMEOUT",
        "originalError": {
            "errorType": "RequestError",
            "errorMessage": "Timeout: Request failed to complete in 15000ms",
            "code": "ETIMEOUT",
            "message": "Timeout: Request failed to complete in 15000ms",
            "stack": [
                "RequestError: Timeout: Request failed to complete in 15000ms",
                "    at RequestError (/var/task/node_modules/mssql/node_modules/tedious/lib/errors.js:32:12)",
                "    at Connection.requestTimeout (/var/task/node_modules/mssql/node_modules/tedious/lib/connection.js:1212:46)",
                "    at Timeout._onTimeout (/var/task/node_modules/mssql/node_modules/tedious/lib/connection.js:1180:14)",
                "    at listOnTimeout (internal/timers.js:549:17)",
                "    at processTimers (internal/timers.js:492:7)"
            ]
        },
        "name": "RequestError",
        "number": "ETIMEOUT",
        "precedingErrors": [],
        "stack": [
            "RequestError: Timeout: Request failed to complete in 15000ms",
            "    at Request.userCallback (/var/task/node_modules/mssql/lib/tedious/request.js:429:19)",
            "    at Request.callback (/var/task/node_modules/mssql/node_modules/tedious/lib/request.js:56:14)",
            "    at Connection.endOfMessageMarkerReceived (/var/task/node_modules/mssql/node_modules/tedious/lib/connection.js:2407:20)",
            "    at Connection.dispatchEvent (/var/task/node_modules/mssql/node_modules/tedious/lib/connection.js:1279:15)",
            "    at Parser.<anonymous> (/var/task/node_modules/mssql/node_modules/tedious/lib/connection.js:1072:14)",
            "    at Parser.emit (events.js:315:20)",
            "    at Parser.EventEmitter.emit (domain.js:482:12)",
            "    at Parser.<anonymous> (/var/task/node_modules/mssql/node_modules/tedious/lib/token/token-stream-parser.js:37:14)",
            "    at Parser.emit (events.js:315:20)",
            "    at Parser.EventEmitter.emit (domain.js:482:12)"
        ]
    },
    "promise": {},
    "stack": [
        "Runtime.UnhandledPromiseRejection: RequestError: Timeout: Request failed to complete in 15000ms",
        "    at process.<anonymous> (/var/runtime/index.js:35:15)",
        "    at process.emit (events.js:315:20)",
        "    at process.EventEmitter.emit (domain.js:482:12)",
        "    at processPromiseRejections (internal/process/promises.js:209:33)",
        "    at processTicksAndRejections (internal/process/task_queues.js:98:32)"
    ]
}

0 个答案:

没有答案