BeeSection BeeSection

How it works inside - why two administrators cannot seat two clients at the same time

Checking that "the time is free" and saving the booking are two separate actions, and a second booking can slip in between them. How a database-level lock closes that gap for the CRM, online booking and the calendar at once.

BeeSection · · 3 min read
Read in another language: Русский Українська

A double booking looks harmless: two bookings at 14:00 with the same specialist. The consequences are not harmless: one client leaves, and the specialist finds out when both are standing at the door.

Where the gap comes from

Saving a booking works as "read, then write": first we check whether the time is free, then we save. Milliseconds pass between those two actions, but two administrators who pressed "Save" at the same moment both pass the check. Each saw free time, and each was right: at the moment of checking it was free.

No interface solves this. The database does.

A lock per specialist

Before checking, the booking takes a named lock in the database: "booking: company such-and-such, specialist such-and-such". A second save for the same specialist waits until the first releases the lock, and only then checks the time. The check now sees the first booking and refuses.

The lock per specialist

The lock is held for no more than 5 seconds. If it cannot be obtained within 5 seconds, saving returns a "please try again" error: holding a request longer for one slot makes no sense, and 5 seconds never happen in normal operation.

One lock for every path

Bookings are created from four places: the form in the CRM, dragging in the calendar, the client's online booking, and internal services such as the waiting list. The lock is the same for all of them. Online booking used to have its own lock and the CRM none, so a client on the website and an administrator in the CRM could still take the same time: the protection worked only between two website clients.

So the lock name is identical across every path. That is the whole point: not a "smarter check" but one queue for everyone who wants this time with this specialist.

What it means in practice

Two administrators press "Save" at once: one booking is created, the other sees "time taken" and picks another. A client on the website and an administrator compete the same way. You will not notice a delay: the lock lives for tens of milliseconds.

If you do see "please try again", just repeat: it means the database was busy for more than 5 seconds, and repeating is better than getting two bookings.

Was this article helpful?

Related articles

Comments

No comments yet. Ask your question — we answer within a day.

Leave a comment

Your email is not published. We use it only to answer you.