Check out the Build Series here.
When I first shipped DraftKit’s public booking pages, I had a silent problem I had not anticipated. The booking form accepted any date a visitor selected from the calendar. But the approval logic ran in the browser, checked the availability table, and wrote back a blocked date as two separate operations. Two approvals happening within milliseconds of each other could both pass the check, both write successfully, and leave a creator with two active collaborations on the same day.
No error. No flag. Just two confused creators and one collision on the calendar.
The availability table was straightforward to build: an array of available dates per creator, an array of blocked dates. Simple to understand. Easy to break under concurrent writes.
Most builders discover this the same way: a user reports something that should be impossible. By then, the problem has already happened more than once.
The fix was not complex, but the path to finding it required understanding how Postgres array operations work under concurrent load, and why optimistic locking is the wrong instinct for this problem. If you are building any booking, scheduling, or approval-based feature in Supabase right now, this post will save you from finding out the hard way.
This Is an Industry-Wide Problem, Not a Calendar Problem
The double-booking bug I described is one version of a larger pattern: public-facing features with no fallback plan for concurrent edge cases.
According to the Nordic APIs 2026 Reliability Report, AI and ML APIs are the least reliable API category across 215+ services tracked between October 2025 and February 2026. OpenAI averaged one incident every 2.5 days in January 2026. The CockroachLabs State of AI Infrastructure report found that 77% of infrastructure leaders now expect AI to drive at least 10% of all service disruptions in the year ahead.
That stat matters for builders even if your app is not AI-heavy. Every feature you put on a public-facing page inherits the reliability of every dependency it touches. A booking form that calls an AI service for smart matching, sends a confirmation email, and writes to a database runs four separate operations. Any one of them can fail in a way that leaves your data in a bad state.
The calendar conflict is the simplest version of this problem because it has no AI dependency. If you cannot solve it in pure SQL, adding AI to the mix will not help you.
Marily Nika covers this well from the AI PM side: the failure modes that matter are the ones your users discover, not the ones your logs show. A silent double-booking and a silent AI failure look identical from the outside. Both leave the user holding a broken experience with no explanation.
Why Your Booking Logic Misses This
Most booking features are built in two phases. Phase one: make the happy path work. Phase two: test it until the happy path always works.
Phase three, which most builders skip, is designing for concurrent requests. When two visitors book the same date within milliseconds of each other, your API receives two near-simultaneous requests. If your conflict check and your block write are separate operations, both requests pass the check before either one completes the write.
Lovable’s AI will build you a perfectly working booking form on the first pass. It will not build you an atomic conflict check. That part requires understanding what “atomic” means in Postgres and choosing the right SQL pattern deliberately.
The pattern that fixes this collapses the check and the write into a single operation that cannot be split by a concurrent request. More validation in application code does not help here.
The Approach I Follow
When I build any approval or booking feature in DraftKit, I now follow this sequence before anything touches the database:
✅ Store available and blocked dates as separate arrays, never as a single computed field. The available_dates array is what creators manage. The blocked_dates array is what the system manages. Mixing them creates ambiguity about who controls which values.
✅ Never read-then-write a date array in application code. Reading the array in your edge function and then writing it back is two operations. A concurrent request can land between them and cause a conflict you cannot detect.
✅ Use a Postgres UPDATE with a WHERE guard, not an INSERT. The WHERE clause validates the condition at write time, not before it. If two updates hit simultaneously, only one can satisfy the WHERE clause. The other returns zero rows updated, which is your conflict signal.
✅ Check the rows affected count immediately after every blocking write. Zero rows updated means the date was already blocked by a concurrent request. Surface this as a clear error in the UI, not a silent success.
✅ Reschedule writes must follow the same atomic pattern. If a creator reschedules an approved collaboration, the new date needs to be blocked atomically before the old date is released. Doing these in sequence leaves a window where both dates are unblocked simultaneously.



