— The stack

Coach booking conflicts: availability is a preview, not a reservation

Handle coach booking races with an authoritative uniqueness rule, a useful conflict response and a clearly scoped isolated race fixture.

4 min readUpdated 2026-11-05By AptixLabs studio
Prospect A: Sees open slot; Prospect B: Sees same open slot; Authoritative commit: Constraint chooses one winner; Conflict recovery: Refresh without losing detailsAptixLabs · 2026-11-05

Original explanatory diagram using synthetic or proposed states; not a product screenshot. View full-size diagram

An open slot is a preview of availability, not a reservation. Two prospects can view the same time before either commits. Enforce the scheduling invariant at the authoritative write boundary and return a useful conflict result when another request wins. A second availability check improves feedback but cannot close the race by itself.

Begin with the scheduling model: fixed slot starts or arbitrary intervals, one coach or several resources, confirmed states and the cancellation rule. The chosen database constraint must match that model. A guarantee about identical start times is narrower than a guarantee about all overlapping appointments.

Put the invariant beside the write

The reviewed UltraFit360 booking route checks open slots, inserts the booking and maps a uniqueness violation to a slot_taken conflict. The associated migration defines a partial unique index on coach and start time for confirmed bookings. These source observations establish an intended same-start guard, not evidence that the migration is present in every deployed environment.

PostgreSQL documents partial unique indexes as enforcing uniqueness among rows satisfying a predicate. Verify the actual database schema and relevant status transitions in the release under review. If the scheduling model permits arbitrary overlaps, assess a constraint or transaction design appropriate to intervals rather than assuming a start-time key covers them.

PostgreSQL: partial unique indexes

Return a conflict that preserves the prospect’s effort

Illustrative response:
409 Conflict
{ "code": "slot_taken", "refreshAvailability": true }

UI: retain entered details, explain the slot changed,
then let the prospect choose a currently available time.

Keep success confirmation after the authoritative commit. Do not send a booking confirmation because a button was tapped or a preview returned open. If confirmation delivery fails after the booking succeeds, preserve the booking and reconcile messaging separately so a retry does not create another appointment.

Read the isolated fixture at its actual scope

Executed synthetic two-prospect fixture
ProspectPreviewCommit result
AOpen409 conflict
BOpen201 accepted
Final confirmed row countSame coach and start1

The fixture uses in-memory SQLite with a partial unique index. Both threads observe the slot before either writes; writes are serialized to isolate uniqueness from SQLite lock behavior. B happened to win this run. This is an algorithm illustration, not a concurrent PostgreSQL benchmark, API execution or proof of a production booking guarantee.

A release test should run the actual route against an isolated database with the real migration and simultaneous requests. Record response codes, confirmed rows and side effects. Keep the test detached from real calendars, payment accounts and customer notifications.

Decide cancellation and retry interactions

The confirmed-state predicate implies that cancellation status matters to the same-start rule. Specify when the slot becomes bookable again, and test a cancellation racing a new request. Also distinguish a duplicate retry from a different prospect; a timed-out success needs an operation identity or another explicit reconciliation path.

CoachAccountable’s first-party API exposes appointment operations and illustrates that booking is a lifecycle, but it does not define this application’s constraint or prove compatibility. Confirm provider access separately for any proposed external connection.

CoachAccountable: appointment API reference

No exact fictional local booking UI was verified, so the researched screenshot becomes a two-request commit diagram. Acceptance should include same-start contenders, changed slot duration, cancellation, a request timeout and failed confirmation delivery. The review artifact is the invariant and its observed test, with narrower fixture evidence labelled honestly.

Distinguish a conflict from an uncertain success. A definitive slot_taken response means the prospect should choose another slot, while a lost response after commit requires checking the original operation’s outcome. Automatically submitting another booking in both cases can create duplicate intent. Preserve a redacted operation reference and a clear pending state for the uncertain case. The recovery test should verify that the prospect can learn which booking exists before being asked to repeat the entire form.

Ultrafit coach portal

Building ultrafit360

Open the live UltraFit360 Coach portal

Bring one client-to-coach workflow, current data contract and acceptance constraint to discuss a bounded fitness product build or integration pilot.

Explore health fitness app development

Can an open booking slot be treated as reserved?

No. Availability is a preview. The authoritative commit must enforce the scheduling constraint and return a recoverable conflict when another request wins.

Does a second availability check prevent every race?

No. Another request can commit after that check. Enforce the invariant at the authoritative write boundary.

Need help with health & fitness app development?

Tell us about your product, existing stack and the problem you need to solve. We can discuss integration scope, implementation tradeoffs and a practical first milestone.

Start a conversation