<- all tokdocs

Design Ticketmaster: Conditional UPDATE vs Distributed Lock for Seats

By , founder of Mavric and Apso

View on TikTok ->

In the "Design Ticketmaster" system design question, the hard part is making sure one seat never sells twice when 40 people click it at once. A TikTok from SysDesignPrep.com (@sysdesignprep.com) argues that a single conditional UPDATE in the database beats a distributed lock. Its description of the lock failure and of PostgreSQL's behavior is correct, but it skips the standard fix for locks, called fencing tokens.

The problem: many buyers, one seat

The video opens with "6 clicks / 1 seat" over a seat map, with several cursors on seat A-12-3 and the caption "40 people." Every buyer wants the same row in the inventory table. Whatever the system does, exactly one of them should get the seat.

Why not use a distributed lock?

The video calls a distributed lock (it shows Redis and ZooKeeper) "THE TEMPTING ANSWER." Its objection: "But now, two systems have to agree." The lock service and the inventory database each hold part of the truth.

It then describes the failure: "If the lock expires during a garbage collection pause, a second buyer grabs it and the seat sells twice." The diagram shows Buyer A taking the lock, pausing for garbage collection past the lock's time limit, and writing SOLD after Buyer B has also taken the lock and written SOLD.

Martin Kleppmann's essay on distributed locking describes the same failure. A client paused by a stop-the-world garbage collection for longer than its lease still believes it holds the lock and writes after another client has acquired it. Checking the lease right before writing does not help, because the pause can land between the check and the write.

Can a distributed lock be made safe?

Yes, with fencing tokens, which the video does not mention. In Kleppmann's fix, the lock service hands out a number that increases with each acquisition. The storage layer rejects any write carrying a token lower than one it has already seen. A paused client that wakes up with an old token gets refused.

Kleppmann notes that Redlock does not produce such tokens. So the "sells twice" outcome is true of a lock without fencing. With fencing, the database becomes the final judge, which is close to the video's own conclusion, but it still needs a second system the conditional UPDATE avoids.

How does a conditional UPDATE pick one winner?

The video's answer: "Mark the seat held, but only where its status is still available." It continues: "The first request matches one row," "The other 39 match zero rows," and "The where clause is the lock." The clip never shows the SQL.

PostgreSQL's documentation on Read Committed isolation explains why this works. When a second UPDATE reaches a row that another transaction has already changed, it waits for that transaction to finish. If the first one committed, the second re-checks its WHERE clause against the new row. If the row no longer matches, it is skipped.

For an update that sets a seat to held only where its status is available, the first transaction flips the status. Every other transaction waits, re-checks, finds zero matching rows and reports zero rows affected. Each caller learns whether it won from that count. This applies to PostgreSQL. The video does not name a database, and other stores were not checked.

Is "the where clause is the lock" literally true?

No, it is a figure of speech. The database still takes a row lock internally during the UPDATE. The exclusion comes from that row lock plus the re-check of the WHERE clause. What the application avoids is a separate lock service and a retry loop.

The clip does not cover buying several seats at once, which needs all-or-nothing handling. The error response on screen lists taken seats as an array, which hints at multi-seat requests, but the video does not explain what happens when some seats are free and others are not.

What should the losing buyers get?

The video says "Losers get an instant 409 with free seats nearby." The example response is 409 Conflict from POST /v1/holds, with a body naming the taken seat (A-12-3) and two suggestions (A-12-9 and A-13-3).

MDN defines 409 as a request that conflicts with the current state of the target resource, which the client can often fix and resubmit. A seat someone else just took fits that definition. Suggesting nearby seats is a product choice. The video's claim that it makes buyers "try once instead of refreshing 30 times" has no source.

How do seat holds expire?

The video says "the hold carries its own expiry, so an abandoned tab gives the seat back." Its example row shows seat A-12-9 with status held, hold_id h_91 and expires_at 10:04:12, under the title "A HOLD IS A LEASE."

Storing the expiry with the row means no separate process has to remember who holds what. The video does not say how the seat returns to available once the time passes. A background sweeper or a check at read time that treats expired holds as available would both work, and the clip does not specify either.

Is this how Ticketmaster works?

The video does not claim that. The end card frames it as the channel's own answer to the interview question "Design Ticketmaster: Sell 60 000 seats in ten minutes to a million people at once, and never sell one twice." That is a scenario, not a reported Ticketmaster figure. The full breakdown is on sysdesignprep.com, whose home page lists 86 questions. The Ticketmaster page itself did not load.

Bottom line

A conditional UPDATE that only marks a seat held where it is still available gives exactly one winner in PostgreSQL, because later updates wait and re-check the condition. A distributed lock without fencing can sell a seat twice after a garbage collection pause, as Kleppmann describes. Fencing tokens fix that, at the cost of a second system the single UPDATE does not need.

Sources

Published November 17, 2026. Based on a TikTok by @sysdesignprep.com. Full video notes (markdown)