Skip to content

Are there any edge cases when TransactWriteItems might successfully complete only some of the actions?

0

When performing a TransactWriteItems operation, is there any scenario in which AWS cannot guarantee that the operation did not somehow only partially complete? I know that the documentation says:

A TransactWriteItems operation differs from a BatchWriteItem operation in that all the actions it contains must be completed successfully, or no changes are made at all. With a BatchWriteItem operation, it is possible that only some of the actions in the batch succeed while the others do not.

However, my team has been debating the scenario in which a TransactWriteItems operation which returns a 500 InternalServerError. Is there perhaps even a small possibility in this case (or any other) that the transactional nature of the operation could be compromised? I couldn't find any evidence in the docs to support that idea.

asked 2 years ago279 views

2 Answers
2
Accepted Answer

No, Transactions are fully ACID compliant, with an all or nothing commit. Items will never be partially updated. If one of the items in the transaction encountered a 500 exception, the entire transaction is rejected as a result.

AWS
EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

AWS
EXPERT

reviewed 2 years ago

1

Based on the available information, there are no edge cases where TransactWriteItems would successfully complete only some of the actions. The transactional nature of TransactWriteItems is designed to be atomic, meaning all actions either succeed or fail together.

Even in the case of an InternalServerError (500), AWS DynamoDB maintains the integrity of the transaction. The operation is designed to be all-or-nothing, which means that if any part of the transaction fails, including due to an internal server error, the entire transaction is rolled back, and no changes are applied to any of the targeted items.

It's important to note that TransactWriteItems is fundamentally different from BatchWriteItem in this regard. While BatchWriteItem can result in partial success with some items being processed and others failing, TransactWriteItems does not allow for such partial completion.

DynamoDB cancels a TransactWriteItems request under specific circumstances, such as when a condition in one of the condition expressions is not met, when tables in the request are in different accounts or regions, when more than one action targets the same item, when there's insufficient provisioned capacity, or when there are user errors like invalid data formats. In all these cases, the entire transaction is canceled, not partially completed.

While it's understandable that your team is concerned about the InternalServerError scenario, there is no evidence in the documentation or known behavior of DynamoDB that suggests the transactional nature could be compromised, even in this case. The system is designed to maintain transactional integrity even in the face of internal errors.

If you receive an InternalServerError, it's generally safe to assume that the transaction did not complete, and you can retry the operation. However, it's always a good practice to design your application to handle potential edge cases and ensure data consistency through additional checks if absolute certainty is required for your use case.
Sources
TransactWriteItems - Amazon DynamoDB
TransactWriteItem - Amazon DynamoDB
TransactWriteItems - AWS AppSync

answered 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.