TransactWriteItems API对于数量大于10的更新组失败。错误:成员的长度必须小于或等于10

问题描述 投票:0回答:1

问题TransactWriteItems API会为数量大于10的更新组抛出以下错误,即使该API最多可以使用25个。

根据AWS TransactWriteItems API文档:

TransactWriteItems是一个同步写操作,最多可以分组25个动作请求。这些动作可以针对不同的项目表,但不在不同的AWS账户或区域中,没有两个动作可以定位到同一项目。例如,不能同时ConditionCheck和更新相同的项目。的总大小交易中的项目不能超过4 MB。

AWS SDK版本

“ aws-sdk”:“ ^ 2.624.0”

错误

message: 'Member must have length less than or equal to 10',
code: 'ValidationException',
time: 2020-02-24T05:07:02.795Z,
requestId: 'a3952ab2-593e-4164-ad2f-3a000e599cia',
statusCode: 400,
retryable: false,
retryDelay: 48.36097368479314 } 
'ValidationException*: Member must have length less than or equal to 10 at Request.extractError (node_modules/aws-sdk/lib/protocol/json.js:51:27)\n    at Request.callListeners (node_modules/aws-sdk/lib/sequential_executor.js:106:20)\n    at Request.emit (node_modules/aws-sdk/lib/sequential_executor.js:78:10)\n    at Request.emit (node_modules/aws-sdk/lib/request.js:683:14)\n    at Request.transition (node_modules/aws-sdk/lib/request.js:22:10)\n    at AcceptorStateMachine.runTo (node_modules/aws-sdk/lib/state_machine.js:14:12)\n    at node_modules/aws-sdk/lib/state_machine.js:26:10\n    at Request.<anonymous> (node_modules/aws-sdk/lib/request.js:38:9)\n    at Request.<anonymous> (node_modules/aws-sdk/lib/request.js:685:12)\n    at Request.callListeners (node_modules/aws-sdk/lib/sequential_executor.js:116:18)'

代码:

var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB({
    'region': 'eu-west-1'
});

// Throws the error if the TransactItems array is > 10
var params = {
    TransactItems: [{
        Update: {
            Key: { "id": { "S": "ABC-XYABV2-2019" }},
            ExpressionAttributeNames: { "#s": "s" },
            ExpressionAttributeValues: { ":s": { "S": "OHIO" } },
            UpdateExpression: "SET #s = :s",
            TableName: "test-order-dev"
        }
    }, 
    ...
    ....
    .....
    {
        Update: {
            Key: { "id": { "S": "CDE-ZUABV2-2020" }},
            ExpressionAttributeNames: { "#s": "s" },
            ExpressionAttributeValues: { ":s": { "S": "OHIO" } },
            UpdateExpression: "SET #s = :s",
            TableName: "test-order-dev"
        }
    }
]
};
dynamodb.transactWriteItems(params, function (err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else console.log(data); // successful response
});

我刚刚找到一个AWS Forum link,它描述了相同的问题,并提示您使用最新的SDK版本。我正在使用最新的SDK版本,想知道可能是什么问题。如果存在,请分享您的想法或解决方案:-)

node.js amazon-dynamodb aws-sdk aws-sdk-js
1个回答
0
投票
None
热门问题
推荐问题
最新问题