On paper, a booking system is one of the friendliest backends you can build. Some rooms, a table of bookings, a page of free slots, a cancel button. Whatever you pick in Node.js, the first version takes an afternoon. Then two people click "Book" on the same 10:00 slot a few milliseconds apart, and both of them get a confirmation.
The obvious fix is a check in the service: query for a confirmed booking of that room whose times cross the new one's, and only insert when the query comes back empty. It reads correctly, and it passes any test that sends one request at a time. Send two of those requests at the same moment, though, and each runs its query before the other has written anything, so each sees an empty calendar and each writes a booking. The race test at the end of this post ran ten users against that version, and it accepted between five and ten bookings of the one slot, in each of five runs.
So in this app, the rule isn't enforced by application code at all.…