New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] The function in aws-node-express-dynamodb-api is not idempotent #657
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The function of writing username in index.js under aws-node-express-dynamodb-api is not idempotent and may cause data inconsistency.
Assuming two concurrent functions want to change the user name with the same userId. When one of them fails after executing
dynamodb_client.put
, AWS Lambda will retry it and change the user name again. Then the client will see the username is changed between two different names repeatedly even if there are only two functions changing the name. This should not happen if every function is executed only once and causes data inconsistency.This can be fixed by making the function idempotent. DynamoDB has provided an idempotent write operation called TransactWriteItems. Replacing
dynamodb_client.put
with it can fix the idempotence bug. Users need to provide a unique client token to be the parameter of TransactWriteItems API. which helps DynamoDB to determine whether the incoming write is a retry.The text was updated successfully, but these errors were encountered: