状态机中的Step函数停止过渡到下一个状态



我一直在使用状态机生成pdf。问题是它运行正常,但在7月23日,这停止了自动工作。我的第一步被成功调用,但没有将数据传递给下一步并超时。

  • 尝试增加超时时间,但不成功。
  • 尝试增加"状态转换节流令牌桶大小"的配额;它也不工作
  • 日志显示在步骤中完成执行,但当通过回调向下一步lambda发送数据时给出超时错误。

在下面附上我的lambda函数

'use strict'
var db = require('database-layer');
const AWS = require('aws-sdk');
const s3 = new AWS.S3();
exports.lambdaHandler =  (event, context, callback) => {
console.log(event);
const bucket = process.env['S3_BUCKET_NAME'] || '';
// This will allow us to freeze open connections to a database
var data = event;
var blogPayload = data.sqsPayload
try {
db.helpers.blogHelper.findHelper({_id: blogPayload._id, type: 'BLOG'}, (_, res) => {
if(res.data){
// create html file and send s3 uri
let newHtmlContent = res.data.content +  embedSignatureInHtml(data.sqsPayload.signaturePayload);
newHtmlContent = `<!DOCTYPE html><html><head><meta charset="UTF-8"></head><body style="font-family: Dejavu Sans;">${newHtmlContent}</body></html>`
var lambdaRequestId = context.awsRequestId;
const output_filename = `html-file/${lambdaRequestId.replace(/.[^.]+$/, '')}.html`
const s3PutParams = {
Bucket: bucket,
Key: output_filename,
Body: newHtmlContent,
ContentType: 'text/html',
Metadata: { "x-amz-meta-requestId": lambdaRequestId }
};
s3.upload(s3PutParams, function(error, uploadData) {
if ( error ) {
console.error('s3:putObject failed!');
callback(null, {
'isAllowed': false,
'sqsQueData': data.sqsQueData
});
return;
}
console.log(uploadData, ' data found and uploaded successfully.');
callback(null, {
'isAllowed': true,
'sqsQueData': data.sqsQueData,
'sqsPayload': data.sqsPayload,
'uploadedHtmlUri': process.env.APP_CDN + uploadData.Key,
});
});

} else {
console.log('data not found', res)
callback(null, {
'isAllowed': false,
'sqsQueData': data.sqsQueData
});
}
});
}catch (e) {
console.log(e.toString());
callback(null, {
'isAllowed': false,
'sqsQueData': data.sqsQueData
});
}
}

这是之前工作得很好的状态机定义,但现在不知何故崩溃了。

{
"Comment": "A state machine that generates pdf and update the system",
"StartAt": "Check Proposal",
"States": {
"Check Proposal": {
"Type": "Task",
"Resource": "${CheckProposalFunctionArn}",
"Retry": [
{
"ErrorEquals": [
"States.TaskFailed"
],
"IntervalSeconds": 2,
"MaxAttempts": 0,
"BackoffRate": 1.5
}
],
"Next": "Generate Or Not?"
},
"Generate Or Not?": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.isAllowed",
"BooleanEquals": true,
"Next": "Generate Pdf"
}
],
"Default": "Update SQS"
},
"Generate Pdf": {
"Type": "Task",
"Resource": "${GeneratePdfFunctionArn}",
"Retry": [
{
"ErrorEquals": [
"States.TaskFailed"
],
"IntervalSeconds": 2,
"MaxAttempts": 1,
"BackoffRate": 1
}
],
"Next": "Update Or Not?"
},
"Update Or Not?": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.isAllowed",
"BooleanEquals": true,
"Next": "Update Pdf"
}
],
"Default": "Update SQS"
},
"Update Pdf": {
"Type": "Task",
"Resource": "${UpdatePdfUrlFunctionArn}",
"Retry": [
{
"ErrorEquals": [
"States.TaskFailed"
],
"IntervalSeconds": 2,
"MaxAttempts": 1,
"BackoffRate": 1
}
],
"Next": "Update SQS"
},
"Update SQS": {
"Type": "Task",
"Resource": "${UpdateSQSFunctionArn}",
"Retry": [
{
"ErrorEquals": [
"States.TaskFailed"
],
"IntervalSeconds": 2,
"MaxAttempts": 2,
"BackoffRate": 1
}
],
"End": true
}
}
}

您尝试过增加Lambda内存吗?这个Lambda会超过15分钟吗?

相关内容

最新更新