MaxConcurrency 属性如何用于 AWS Step Functions 中的映射任务?

How does the MaxConcurrency attribute work for the Map Task in AWS Step Functions?

更新:Map State 步骤模板和 运行 创建步骤函数也会引发错误。这是 MaxConcurrency 属性和 Parameters 值不起作用的有力证据。

我无法在步骤函数定义中成功使用 MaxConcurrency 属性。

这可以通过使用 documentation 中为地图任务(2019 年 9 月 18 日新增)中提供的示例来证明:

{
  "StartAt": "ExampleMapState",
  "States": {
    "ExampleMapState": {
      "Type": "Map",
      "MaxConcurrency": 2,
      "Parameters": {
        "ContextIndex.$": "$$.Map.Item.Index",
        "ContextValue.$": "$$.Map.Item.Value"
      },
      "Iterator": {
         "StartAt": "TestPass",
         "States": {
           "TestPass": {
             "Type": "Pass",    
             "End": true
           }
         }
      },
      "End": true
    }
  }
}

通过使用以下输入执行步进函数:

[
  {
    "who": "bob"
  },
  {
    "who": "meg"
  },
  {
    "who": "joe"
  }
]

我们可以在执行事件历史记录中观察到:

步进函数失败。 ExecutionFailed 步骤具有以下输出(省略执行 ID):

{
  "error": "States.Runtime",
  "cause": "Internal Error (omitted)"
}

尝试使用 Catch 步骤捕获错误无效。

我在这里做错了什么?这是一个错误吗?

对今天早上提交给 AWS 的私人工单的回应;

Thank you for contacting AWS Premium Support. My name is Akanksha and I will be assisting you with this case.

I understand that you have been working with the new Map state feature of step functions and have noticed that when we use Parameters along with MaxConcurrency set to lower value than the number of iterations (with only first iteration successful) it fails with ‘States.Runtime’ and looks like a bug with the functionality.

Thank you for providing the details. It helped me during troubleshooting. In order to confirm the behavior, I used the below state machine example with Pass:

{ "StartAt": "Map State", "TimeoutSeconds": 3600, "States": { "Map State": { "Type": "Map”, "Parameters": { “ContextValue.$”: "$$.Map.Item.Value" }, "MaxConcurrency": 1, "Iterator": { "StartAt": "Run Task", "States": { "Run Task": { "Type": "Pass", "End": true } } }, "Next": "Final State" }, "Final State": { "Type": "Pass", "End": true } } }

I tested with multiple input lists and MaxConcurrency values and below are my observations:

  1. Input size list: 4 MaxConcurrency:1/2/3 - Fails and MaxConcurrency:0/4/5 or above - Works
  2. Input size list: 3 MaxConcurrency: 1/2 - Fails and MaxConcurrency:0/3/4 or above - Works
  3. Similarly, I performed tests by removing the parameters from state machine as well and could see that it works as expected with different MaxConcurrency values.
  4. I also tested the same by changing the Task type of “Pass” with “Lambda” and observed the same behavior.

Hence, I can confirm that the state machine fails when we have parameters in the code and specify MaxConcurrency value as anything other than zero or the number greater than or equal to the list size.

After doing some research regarding this behavior to check if this is intended, I could not find much information regarding the same as this is a new feature. So, I will be reaching out to the internal team with all the details and the example state machine that you have provided. Thank you for bringing this to our notice. I will get back to you as soon as I have an update from the internal team. Please be assured that I will regularly follow up with the team and work with them to investigate further.

Meanwhile, if you have any other queries or concerns, please do let me know.

Have a great day ahead!

当我获得更多信息时,我会在这里更新。