DynamoDB sometime returns "Requested resource not found" when run dynamo.send(GetCommand) in parallel

0

This is my Lambda code:

async function getDataFromDB(param) {
    (0, lambda_utils_utility_1.utility_printf)(getDataFromDB, arguments);
    const command = new lib_dynamodb_1.GetCommand(param);
    try {
        const result = await dynamo.send(command);
        return result.Item;
    }
    catch (err) {
        console.error(`An error has occurred on getDataFromDB.\nerror message => "${err?.message}"\narguments => `, arguments);
        throw err;
    }
}

When I run on parallel to get from same Table, sometime below error occurred

{
    ""level"": ""ERROR"",
    ""message"": ""--getDataFromDB"",
    ""service"": ""service_undefined"",
    ""timestamp"": ""2024-03-04T08:53:06.247Z"",
    ""xray_trace_id"": ""1-65e58bd6-55b0a6b3fa6e6d2e88640a00"",
    ""error"": {
        ""name"": ""ResourceNotFoundException"",
        ""location"": ""/var/runtime/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:2879"",
        ""message"": ""Requested resource not found"",
        ""stack"": ""ResourceNotFoundException: Requested resource not found\n    at de_ResourceNotFoundExceptionRes (/var/runtime/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:2879:23)\n    at de_GetItemCommandError (/var/runtime/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:1552:25)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async /var/runtime/node_modules/@aws-sdk/node_modules/@smithy/middleware-serde/dist-cjs/deserializerMiddleware.js:7:24\n    at async /var/runtime/node_modules/@aws-sdk/lib-dynamodb/dist-cjs/baseCommand/DynamoDBDocumentClientCommand.js:29:34\n    at async /var/runtime/node_modules/@aws-sdk/middleware-signing/dist-cjs/awsAuthMiddleware.js:30:20\n    at async /var/runtime/node_modules/@aws-sdk/node_modules/@smithy/middleware-retry/dist-cjs/retryMiddleware.js:27:46\n    at async /var/runtime/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:7:26\n    at async getDataFromDB (/opt/nodejs/node_modules/@mui/lambda-utils/dist/lib/dynamodb/lambda_utils.dynamodb.js:75:24)\n    at async getSummaryInfo (/var/task/app.js:476:21)\n    at async handleUpdateOnePaymentOfServNo (/var/task/app.js:75:33)\n    at async handleUpdateDataByServNo (/var/task/app.js:61:9)\n    at async Runtime.lambdaHandler [as handler] (/var/task/app.js:42:13)""
    }
}

Please tell me how to fix

Do Khoi
已提问 2 个月前238 查看次数
1 回答
-1

The section of code you show is a simple GetItem call as is not responsible for the exception you are seeing. GetCommand takes multiple parameters, including TableName, which you may be changing dynamically before calling getDataFromDB.

How to rule out the possible causes:

  1. In your catch block, print the GetItem command parameters.
  2. Check that you don't specify the wrong region when you create your DynamoDB client.
  3. Ensure your Lambda isn't using multiple versions.
  4. Add additional logging where appropriate.
profile pictureAWS
专家
已回答 2 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则