skip to Main Content

I’m getting timeout error because need to migrate a dynamodb table to the new one. There are many items in old table.So, i’m using lastevaluatedkey for pagination to read operations, but lambda functions live 15 minutes. So, I create a step function as below:

{
  "Comment": "DynamoDB Scan Workflow",
  "StartAt": "ScanDynamoDB",
  "States": {
    "ScanDynamoDB": {
      "Type": "Task",
      "Resource": "arn:aws:lambda:us-east-1:**********:function:dynamo-table-migrator",
      "Next": "IsScanComplete"
    },
    "IsScanComplete": {
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.LastEvaluatedKey",
          "IsPresent": true,
          "Next": "ScanDynamoDB"
        }
      ],
      "Default": "Done"
    },
    "Done": {
      "Type": "Succeed"
    }
  }
}

My lambda function’s timeout is 10 minutes. I increased it from 30 seconds and it actually migrate almost half of the table but then again gives error. The error:

The cause could not be determined because Lambda did not return an error type. Returned payload: {"errorMessage":"2024-01-10T06:55:49.427Z 4730971c-c428-4692-aa23-4486932da4f2 Task timed out after 600.18 seconds"}

2

Answers


  1. I hope this is one time process to migrate table: I mean not usual task for you.

    Just check once if you can improve process:

    • are you reading and writing data from both tables in the same lambda call.
    • Just check if you can already read and prepare data.

    Quick Way:

    Other Way:

    • you can export data to file.
    • prepare new data using your code and store it in Dynamo as you are doing already.
    • Just don’t read and write at once.
    Login or Signup to reply.
  2. Unfortunately, I do not have enough reputation to comment.

    What is the allocated memory for the lambda function?
    You could potentially increase it if the load is too heavy. Naturally, this has its limit though and comes at a higher cost.

    See also the documentation Lambda Memory Optimization.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search