Conditional Writes in DynamoDB
Talk it through out loud with your AI coach.
The problem
- hard
- Pro
Two instances of a .NET service read the same stock record from DynamoDB, each subtracts one and writes it back, and the shop oversells. Separately, a retried request creates a duplicate order. Explain how to use DynamoDB's conditional writes and transactions to prevent both.
What a strong answer covers
- Why read-modify-write loses updates under concurrency.
- Making a write depend on the current state of the item.
- Turning a retried request into a no-op.
- Grouping writes that must succeed or fail together.
Common mistake: Adding a lock inside the .NET service, which does nothing when several instances write to the same table.
Knowing this is half of it. Saying it clearly out loud is the part the coach helps you practise.
Practise it out loud