首页 > 解决方案 > AWS Step 函数重试逻辑,最大 IntervalSeconds?

问题描述

我正在使用 AWS Step 功能步骤,更具体地说是错误处理。

在本文档中:https ://docs.aws.amazon.com/step-functions/latest/dg/concepts-error-handling.html ,它提到Retry如果步骤无法重试该步骤,我们可以使用该子句:

"Retry": [ {
   "ErrorEquals": [ "States.Timeout" ],
   "IntervalSeconds": 3,
   "MaxAttempts": 2,
   "BackoffRate": 1.5
} ]

我可以设置IntervalSeconds的最大值是多少?MaxAttempts我希望能够重试 2-4 天,每 4 小时重试一次。是否可以将这些字段设置为如此高的值?例子:

"Retry": [ {
   "ErrorEquals": [ "States.ALL" ],
   "IntervalSeconds": 14400,
   "MaxAttempts": 12,
   "BackoffRate": 1
} ]

标签: aws-step-functions

解决方案


IntervalSeconds和的最大值MaxAttempts99999999。我在文档中没有看到任何提及,但您可以通过尝试在控制台中或使用 API 创建示例状态机来进行验证。IE

{
    "Comment": "A Retry example of the Amazon States Language using an AWS Lambda Function",
    "StartAt": "HelloWorld",
    "States": {
        "HelloWorld": {
            "Type": "Task",
            "Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME",
            "Retry": [
                {
                    "ErrorEquals": ["CustomError"],
                    "IntervalSeconds": 99999999,
                    "MaxAttempts": 99999999,
                    "BackoffRate": 2.0
                },
                {
                    "ErrorEquals": ["States.TaskFailed"],
                    "IntervalSeconds": 99999999,
                    "MaxAttempts": 99999999,
                    "BackoffRate": 2.0
                },
                {
                    "ErrorEquals": ["States.ALL"],
                    "IntervalSeconds": 99999999,
                    "MaxAttempts": 99999999,
                    "BackoffRate": 2.0
                }
            ],
            "End": true
        }
    }
}

推荐阅读