ACID Transactions

DynamoDB supports ACID transactions with some limitations.

Section preview

In computer science, ACID is a set of properties of database transactions intended to guarantee data validity despite errors, power failures, and other mishaps. In the context of databases, a set of database operations that satisfies the ACID properties is called a transaction.

ACID

  • Atomicity property guarantees that all item manipulation operations in the transaction will either commit or rollback

  • Consistency properties refers to a guarantee that even if there are failures in one or more operations in the transaction - data will always be in a consistent state irrespective of whether the txn committed or rolled back

  • Isolation property guarantees that item operations carried out in parallel will behave as if they are sequential

  • Durability property guarntess that once the transaction is committed - the data is guaranteed to be available in the persistent storage

DynamoDB Transactions

  • Released in 2018
  • Allows up to 100 operations in a single API call
  • Maximum data allowed in a single transaction = 4 MB
  • May be across multiple tables within the same region owned by same account

Transaction API

are for Executing multiple all-or-nothing actions within & across tables with a single API.

  • The operation can be carried out across multiple items
  • The operation can be carried out across multiple tables within same region belonging to the same AWS account

All or Nothing?

  • Transaction API is successful (committed) if and only if all operations are successful
  • Transaction API fails if ANY operation fails

all-or-nothing

Condition Checks

Transacton API supports 2 types of condition checks. First one is at the item level - its available for put, update and delete item operations - you have already seen the Condition Expression in action in one of the earlier lessons

For transactional writes there is a condition check at transaction level. Idea is that if any of the conditions fail the transaction is rolled back

Cost of Transaction API

  • Costs double of standard write operation (1 KB chunks)
  • Costs double of standard read (strongly consistent) operation (4 KB chunks)

all-or-nothing