All entries

    Prevent Double Bookings with Expiring Slot Holds

    A temporary booking hold should be claimed atomically because two clients can see the same available slot.

    Two booking desks compete for a single secured slot
    Conceptual pixel-art illustration.

    A temporary booking hold should be claimed atomically because two clients can see the same available slot.

    Build the example

    Give a fictional appointment slot an expiration time and one active hold. In a transaction, lock or conditionally update the slot if it is free or expired. Use server time, bind the hold to its owner and require that the hold is current when converting it to a confirmed booking.

    Use the same test fixture for booking requests made nearly simultaneously and for sequential requests near expiry. Log the server’s claim time and resulting hold owner in the fixture output. Then test what happens if a payment callback arrives after expiration. The booking and payment systems may require a separate reconciliation step.

    EXPLAINED / SEQUENCE

    Concurrent appointment claims

    A temporary booking hold should be claimed atomically because two clients can see the same available slot.

    Example

    1. Both clients

      see an available slot

    2. First transaction

      claims the hold

    3. Second transaction

      sees the active claim and rejects the overlap

    THE KEY DISTINCTION

    sees the active claim and rejects the overlap

    Conceptual diagram for the synthetic example in this guide.

    Watch the failure boundary

    Expired holds still need correct behavior before a cleanup task runs. Check expiry while claiming the slot rather than relying on a background deletion. Use a uniqueness constraint or transactional lock around the resource. Decide what happens if the client begins confirmation just before the hold expires and the server receives it afterward.

    Verify the behavior

    Start two sessions and make them request the same slot concurrently. Exactly one should receive an active hold. Advance the test clock past expiry, create a new hold, and attempt to confirm the old one. Check that retrying a successful confirmation returns the original booking.

    FURTHER READING

    Sources

    Technical references checked .

    END OF ENTRY / 59
    Eeshan Singh with Big Ben in London
    BEHIND THE JOURNAL

    Eeshan Singh

    I’m Eeshan Singh Pokharia, an AI Full Stack Developer and CoFounder of UltraFit360. I work across AI features, full-stack product development, and web and mobile experiences—from Figma and frontend interactions to the systems behind them.

    Expired holds still need correct behavior before a cleanup task runs. Check expiry while claiming the slot rather than relying on a background deletion. Use a uniqueness constraint or transactional lock around the resource. Decide what happens if the client begins confirmation just before the hold expires and the server receives it afterward.

    Meet the author
    THE CONVERSATION

    Your side of the story.