Dynamodb medium
To implement Optimistic Locking in an inventory system, a developer includes a `ConditionExpression: 'version = :old_v'`. If another process has already updated the item, what specific error should the application handle?
- A ResourceNotFoundException
- B ConditionalCheckFailedException
- C ValidationException
- D TransactionConflictException
Answer: B. ConditionalCheckFailedException
Conditional Writes ensure atomicity. If the condition is not met (i.e., the version in the database is no longer what the client expected), the write is rejected with a `ConditionalCheckFailedException`. This prevents 'Lost Updates' in high-concurrency environments without requiring expensive global locks.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- DynamoDB has a strict 400KB limit on the size of a single item. What is the recommended design pattern if you need to store larger documents (e.g., 5MB PDFs)?
- What is the primary role of the 'Partition Key' in ensuring DynamoDB's infinite horizontal scalability?
- Why is the `Query` operation generally preferred over `Scan` for production workloads in DynamoDB?
- DynamoDB is a 'fully managed' serverless database. What is a primary operational benefit of this model for an engineering team?
- In 'Provisioned Capacity' mode, how is the performance budget of a DynamoDB table defined?
- When would an architect choose to implement DAX (DynamoDB Accelerator) in front of an existing DynamoDB table?