So I’ll try to be as precise as I can in my issue. I am currently using a amazon/dynamodb-local docker image within my project. The stack also contains nodejs services.

The issue I have noticed is that whenever I start the stack and then try to perform an update operation on one of my tables, it actually creates a duplicate record with updated values instead of updating the original record. Due to this I now get two records with same partition keys that I an unable to delete or do anything on them. The only way to get rid of it is to delete and re-create the table.

r/webdev - Backend DynamoDB -Local Update Issue

This is the value of the table when I deploy it. Now when I run the update operation, the commition_limit value should be reflected as 9.

r/webdev - Backend DynamoDB -Local Update Issue

After running the update operation this is the result that I get

Now the temporary work around that I have been able to find is that, whenever I stop and restart my whole docker containers, I have to delete all these tables and re-intialize them. Once I do this, all the tables and the update queries work fine. But if i ever stop the whole stack (lets say at the end of the day) and restart it tomorrow, I again have to go through the deletion and re-initialization thing again.

The table definition :

{
TableName: "commission",
KeySchema: [
{ AttributeName: "public_key", KeyType: "HASH" }, //Partition key
],
AttributeDefinitions: [{ AttributeName: "public_key", AttributeType: "S" }],
ProvisionedThroughput: {
ReadCapacityUnits: 5,
WriteCapacityUnits: 5,
},
}

The update query :

{
TableName: "commission",
Key: {
"public_key": publickey
},
UpdateExpression: "set commission = :commission , commission_limit = :commissionlimit ",
ExpressionAttributeValues: {
":commission": commission,
":commissionlimit": commissionlimit
},
ReturnValues: "UPDATED_NEW"
}

The same thing is affecting all the tables.

Is this a bug or am i missing something here. Any help is appreciated!



Source link

Write A Comment