使用无服务器工作流Go SDK时出现间歇性的JSON解组错误。

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

Intermittent JSON Unmarshalling Error when using serverless workflow go sdk

问题

我有一个仓库https://github.com/BuilderHarrison/temporal-hello-world-dsl,当我运行它时,有50%的概率失败,50%的概率成功。我对Temporal和Serverless SDK都非常陌生,所以我无法弄清楚如何进行故障排除。我遇到的问题是:

{
  "type": "workflowExecutionFailedEventAttributes",
  "failure": {
    "message": "无法解码工作流函数输入有效负载,错误为:有效负载项0:无法解码:json:无法将对象解组为类型为字符串的Go结构体字段Workflow.Start,函数名称:HelloWorld",
    "source": "GoSDK",
    "stackTrace": "",
    "cause": {
      "message": "有效负载项0:无法解码:json:无法将对象解组为类型为字符串的Go结构体字段Workflow.Start",
      "source": "GoSDK",
      "stackTrace": "",
      "cause": {
        "message": "无法解码:json:无法将对象解组为类型为字符串的Go结构体字段Workflow.Start",
        "source": "GoSDK",
        "stackTrace": "",
        "cause": {
          "message": "无法解码",
          "source": "GoSDK",
          "stackTrace": "",
          "cause": null,
          "applicationFailureInfo": {
            "type": "",
            "nonRetryable": false,
            "details": null
          }
        },
        "applicationFailureInfo": {
          "type": "wrapError",
          "nonRetryable": false,
          "details": null
        }
      },
      "applicationFailureInfo": {
        "type": "wrapError",
        "nonRetryable": false,
        "details": null
      }
    },
    "applicationFailureInfo": {
      "type": "wrapError",
      "nonRetryable": false,
      "details": null
    }
  },
  "retryState": "RetryPolicyNotSet",
  "workflowTaskCompletedEventId": "7",
  "newExecutionRunId": ""
}

供参考的JSON文件如下:

{
	"id": "helloworld",
	"version": "1.0",
	"specVersion": "0.8",
	"name": "Hello World Workflow",
	"description": "Hello World",
	"start": "Hello State",
	"states": [
	  {
		"name": "Hello State",
		"type": "operation",
		"actionMode": "sequential",
		"actions": [
		  {
			"functionRef": {
			  "refName": "PrintHelloWorld1",
			  "arguments": {
				"arg1": "Hello World1!"
			  }
			}
		  },
			{"functionRef": {
				"refName": "PrintHelloWorld2",
				"arguments": {
				  "arg1": "Hello World2!"
				}
			  }
			}
		],
		"end": true
	  }
	]
  }

希望能得到帮助!

祝好,
Harrison

英文:

i've got a repo https://github.com/BuilderHarrison/temporal-hello-world-dsl and when i run it, it fails 50% of the time and succeeds 50% of the time. I am very new to both temporal and the serverless sdk. So im unable to quite figure out how to proceed with debugging the issue. The issue im getting is:

{
  "type": "workflowExecutionFailedEventAttributes",
  "failure": {
    "message": "unable to decode the workflow function input payload with error: payload item 0: unable to decode: json: cannot unmarshal object into Go struct field Workflow.Start of type string, function name: HelloWorld",
    "source": "GoSDK",
    "stackTrace": "",
    "cause": {
      "message": "payload item 0: unable to decode: json: cannot unmarshal object into Go struct field Workflow.Start of type string",
      "source": "GoSDK",
      "stackTrace": "",
      "cause": {
        "message": "unable to decode: json: cannot unmarshal object into Go struct field Workflow.Start of type string",
        "source": "GoSDK",
        "stackTrace": "",
        "cause": {
          "message": "unable to decode",
          "source": "GoSDK",
          "stackTrace": "",
          "cause": null,
          "applicationFailureInfo": {
            "type": "",
            "nonRetryable": false,
            "details": null
          }
        },
        "applicationFailureInfo": {
          "type": "wrapError",
          "nonRetryable": false,
          "details": null
        }
      },
      "applicationFailureInfo": {
        "type": "wrapError",
        "nonRetryable": false,
        "details": null
      }
    },
    "applicationFailureInfo": {
      "type": "wrapError",
      "nonRetryable": false,
      "details": null
    }
  },
  "retryState": "RetryPolicyNotSet",
  "workflowTaskCompletedEventId": "7",
  "newExecutionRunId": ""
}

For reference the json file im providing is:

{
	"id": "helloworld",
	"version": "1.0",
	"specVersion": "0.8",
	"name": "Hello World Workflow",
	"description": "Hello World",
	"start": "Hello State",
	"states": [
	  {
		"name": "Hello State",
		"type": "operation",
		"actionMode": "sequential",
		"actions": [
		  {
			"functionRef": {
			  "refName": "PrintHelloWorld1",
			  "arguments": {
				"arg1": "Hello World1!"
			  }
			}
		  },
			{"functionRef": {
				"refName": "PrintHelloWorld2",
				"arguments": {
				  "arg1": "Hello World2!"
				}
			  }
			}
		],
		"end": true
	  }
	]
  }

Any assistance would be appreciated!

Cheers,
Harrison

答案1

得分: 4

50%的错误通常是由于存在两个Worker进程,其中一个是在旧版本/不兼容的代码上运行。你是否有可能在不同的shell或后台中有一个旧的Worker进程?

英文:

The 50%-of-the-time errors are often due to the presence of two Worker processes, one of which is on an older / incompatible version of the code. Is there a chance you have an old Worker process in a different shell or in the background?

huangapple
  • 本文由 发表于 2022年7月26日 15:25:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/73119268.html
匿名

发表评论

匿名网友

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

确定