Two callers are offered the same final appointment slot. Both accept before either booking is saved. A correct availability lookup did not protect the write from a concurrent request.
The booking system needs a rule that arbitrates the last slot at the point where capacity is consumed.
Availability is an observation, not a reservation
Between checking a slot and saving an appointment, another caller or employee may book it. Making the conversation shorter reduces the window but does not remove it.
First decide which system owns availability. If staff and the AI can both create appointments, a local lock in the AI service alone cannot govern every booking path.
For a proposed system under your control, a temporary hold or transactional reservation can help. For an external scheduler, use its supported booking and conflict mechanisms rather than assuming a normal calendar insert rejects all overlaps.
Define who wins and how the other caller recovers
| State | Required behaviour |
|---|---|
| Slot appears free | Offer it provisionally under the chosen flow |
| Capacity is claimed | Preserve an identifiable reservation or accepted booking |
| Another request loses | Offer a valid alternative without false confirmation |
| Hold expires | Release only the intended hold |
Use a stable operation reference for retries. Otherwise, the winning caller's repeated request can consume more than one unit of capacity.
Avoid simplistic uniqueness on a start time when appointments have different durations or use different resources. Two visits can overlap without starting together, and one time can legitimately support several independent staff members.
Model the actual resource constraint
For a fictional workshop, capacity might mean one technician and one service bay for the full interval. Write that invariant before choosing database locks, constraints, or provider APIs.
A hold needs expiry, ownership, and recovery after a worker restart. A hold without cleanup can make a calendar look full indefinitely. A hold that expires during confirmation needs a clear recheck.
The database-constraint guide covers enforceable invariants. It does not imply that a database rule automatically extends to an independent external calendar.
Test simultaneous callers deliberately
Start two fictional booking attempts against the same resource. Delay them so both observe availability before either submits. Verify the accepted count and the losing caller's response.
Repeat with staff booking directly, an expired hold, and a lost provider response. Sequential demo calls will not expose the original race.
Last-slot questions
Is a second availability check enough?
Another write can still occur between that check and the save unless the authority provides stronger guarantees.
Should the AI promise the slot immediately?
Use confirmation only after the agreed reservation or booking requirement succeeds.
Where should we start?
Map all booking paths and the system that owns capacity before designing the integration.