'In DynamoDB TransactWriteItems ConditionCheck in same item as UpdateItem

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?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source