如何捕获AWS分布式映射状态中的错误

huangapple go评论70阅读模式
英文:

How to catch error in AWS distributed map state

问题

我在使用StepFunctions时遇到了一些问题...是否有办法捕获类似于States.ExceedToleratedFailureThreshold的DistributedMaps中的错误?我有类似以下的东西,但不知何故Catch未应用,当至少有一个Lambda失败时,执行就失败了:

{
  "Next": "ReleaseSlot",
  "Type": "Map",
  "ItemReader": {
    "ReaderConfig": {
      "InputType": "CSV",
      "CSVHeaderLocation": "FIRST_ROW"
    },
    "Resource": "arn:aws:states:::s3:getObject",
    "Parameters": {
      "Bucket": "<BUCKET>",
      "Key.$": "$.filename"
    }
  },
  "ItemBatcher": {
    "MaxItemsPerBatch": 1000,
    "BatchInput": {
      "data.$": "$"
    }
  },
  "ItemProcessor": {
    "StartAt": "BatchImporter",
    "States": {
      "BatchImporter": {
        "Type": "Task",
        "Resource": "arn:aws:states:::lambda:invoke",
        "Parameters": {
          "FunctionName": "<FUNCTION_ARN>",
          "Payload": {
            "body": "$"
          }
        },
        "ResultPath": null,
        "OutputPath": null,
        "End": true
      }
    },
    "ProcessorConfig": {
      "Mode": "DISTRIBUTED",
      "ExecutionType": "STANDARD"
    }
  },
  "MaxConcurrency": 16,
  "ToleratedFailurePercentage": 0,
  "Catch": [
    {
      "ErrorEquals": [
        "States.All"
      ],
      "Next": "ReleaseSlot"
    }
  ]
}

我想捕获这个错误,因为如果它发生了,分布式映射将无法运行“ReleaseSlot”状态,这会导致状态不一致。

英文:

I'm facing some issues with StepFunctions... Is there a way to Catch errors like States.ExceedToleratedFailureThreshold in DistributedMaps? I have something like this but somehow the Catch isn't applied and the execution just fails when at least one Lambda is failing:

{
  &quot;Next&quot;: &quot;ReleaseSlot&quot;,
  &quot;Type&quot;: &quot;Map&quot;,
  &quot;ItemReader&quot;: {
    &quot;ReaderConfig&quot;: {
      &quot;InputType&quot;: &quot;CSV&quot;,
      &quot;CSVHeaderLocation&quot;: &quot;FIRST_ROW&quot;
    },
    &quot;Resource&quot;: &quot;arn:aws:states:::s3:getObject&quot;,
    &quot;Parameters&quot;: {
      &quot;Bucket&quot;: &quot;&lt;BUCKET&gt;&quot;,
      &quot;Key.$&quot;: &quot;$.filename&quot;
    }
  },
  &quot;ItemBatcher&quot;: {
    &quot;MaxItemsPerBatch&quot;: 1000,
    &quot;BatchInput&quot;: {
      &quot;data.$&quot;: &quot;$&quot;
    }
  },
  &quot;ItemProcessor&quot;: {
    &quot;StartAt&quot;: &quot;BatchImporter&quot;,
    &quot;States&quot;: {
      &quot;BatchImporter&quot;: {
        &quot;Type&quot;: &quot;Task&quot;,
        &quot;Resource&quot;: &quot;arn:aws:states:::lambda:invoke&quot;,
        &quot;Parameters&quot;: {
          &quot;FunctionName&quot;: &quot;&lt;FUNCTION_ARN&gt;&quot;,
          &quot;Payload&quot;: {
            &quot;body&quot;: &quot;$&quot;
          }
        },
        &quot;ResultPath&quot;: null,
        &quot;OutputPath&quot;: null,
        &quot;End&quot;: true
      }
    },
    &quot;ProcessorConfig&quot;: {
      &quot;Mode&quot;: &quot;DISTRIBUTED&quot;,
      &quot;ExecutionType&quot;: &quot;STANDARD&quot;
    }
  },
  &quot;MaxConcurrency&quot;: 16,
  &quot;ToleratedFailurePercentage&quot;: 0,
  &quot;Catch&quot;: [
    {
      &quot;ErrorEquals&quot;: [
        &quot;States.All&quot;
      ],
      &quot;Next&quot;: &quot;ReleaseSlot&quot;
    }
  ]
}

I wanted to catch this error, as if it occurred then distributed map failed to run "ReleaseSlot" state, which leads to inconsistent state.

答案1

得分: 1

错误名称中的外壳不正确。您需要使用States.ALL(大写的ALL)。

英文:

The casing in your Error name is incorrect. You need to use States.ALL (capitalized ALL).

huangapple
  • 本文由 发表于 2023年5月24日 23:39:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76325259.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定