A temporary booking hold should be claimed atomically because two clients can see the same available slot.
Build the example
Give a fictional appointment slot an expiration time and one active hold. In a transaction, lock or conditionally update the slot if it is free or expired. Use server time, bind the hold to its owner and require that the hold is current when converting it to a confirmed booking.
Use the same test fixture for booking requests made nearly simultaneously and for sequential requests near expiry. Log the server’s claim time and resulting hold owner in the fixture output. Then test what happens if a payment callback arrives after expiration. The booking and payment systems may require a separate reconciliation step.
Concurrent appointment claims
A temporary booking hold should be claimed atomically because two clients can see the same available slot.
Example
- Both clients
see an available slot
- First transaction
claims the hold
- Second transaction
sees the active claim and rejects the overlap
sees the active claim and rejects the overlap
Watch the failure boundary
Expired holds still need correct behavior before a cleanup task runs. Check expiry while claiming the slot rather than relying on a background deletion. Use a uniqueness constraint or transactional lock around the resource. Decide what happens if the client begins confirmation just before the hold expires and the server receives it afterward.
Verify the behavior
Start two sessions and make them request the same slot concurrently. Exactly one should receive an active hold. Advance the test clock past expiry, create a new hold, and attempt to confirm the old one. Check that retrying a successful confirmation returns the original booking.
Sources
Technical references checked .



