In a planning system thousands of users compete simultaneously for the same time slots, stored in DynamoDB. When a user tries to reserve a time slot, a TransactWriteItems should:
- ConditionCheck whether the slot is still available, and if it is
- UpdateItem to reserve the time slot for this user.
However, https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/transaction-apis.html#transaction-isolation says "you can't perform a ConditionCheck and also an Update action on the same item in the same transaction."
How can I make sure that a user can only reserve a time slot that's not (shortly before) reserved by someone else?
CodePudding user response:
You don’t need a transaction. You can just put the item to reserve the time slot and include a condition expression that it fails if it was already taken.