Bird
0
0

This booking system code sometimes allows double booking:

medium📝 Analysis Q7 of 15
LLD - Design — Hotel Booking System
This booking system code sometimes allows double booking:
def book(slot):
    if check_availability(slot):
        confirm_booking(slot)
        update_availability(slot, False)

What is the likely cause?
AAvailability is updated before booking
BNo locking or atomic transaction around check and update
CBooking confirmation is missing
DSlot is never checked for availability
Step-by-Step Solution
Solution:
  1. Step 1: Review booking steps

    Availability is checked, then booking confirmed, then availability updated.
  2. Step 2: Identify missing concurrency control

    Without atomic operation or lock, two users can pass check before update, causing double booking.
  3. Final Answer:

    No locking or atomic transaction around check and update -> Option B
  4. Quick Check:

    Atomicity needed to prevent double booking [OK]
Quick Trick: Use atomic transactions for check and update [OK]
Common Mistakes:
  • Thinking availability update order is wrong
  • Assuming confirmation is missing
  • Ignoring concurrency issues

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes