---
title: "Design Ticketmaster: Conditional UPDATE vs Distributed Lock for Seats"
date: "2026-11-17"
video_id: "7709001236716047647"
tiktok_url: "https://www.tiktok.com/@sysdesignprep.com/video/7709001236716047647"
creator: "@sysdesignprep.com"
category: "Coding"
tags: ["system design", "distributed lock", "postgresql", "design ticketmaster", "fencing token"]
excerpt: "Why a conditional UPDATE stops a seat selling twice, how a distributed lock fails during a GC pause, and the fencing token fix the video leaves out."
---
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

- [How to do distributed locking, Martin Kleppmann, 2016-02-08](https://martin.kleppmann.com/2016/02/08/how-to-do-distributed-locking.html): the lease-expiry failure and fencing tokens.
- [Transaction Isolation, PostgreSQL documentation](https://www.postgresql.org/docs/current/transaction-iso.html): Read Committed behavior for concurrent UPDATE.
- [409 Conflict, MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/409): the meaning of HTTP 409.
- [SysDesignPrep.com](https://sysdesignprep.com): the site behind the video.


## Video description and verification notes

**The file is a 59.71 s vertical clip (ffprobe format duration 59.712993 s; video stream 59.700 s), 720x1280, MP4 (isom), H.264 High at 30 fps (1791 frames, 174,114 bit/s video), with HE-AACv2 stereo audio at 44.1 kHz (64,158 bit/s). Container bitrate is 244,919 bit/s and the file is 1,828,108 bytes. metadata.json gives format id h264_720p_244915-1 and leaves fps null, so I took 30 fps from ffprobe. It was posted at epoch 1794891740, which is 2026-11-17 04:42:20 UTC by my conversion. The upload_date field reads 20261117. The account is @sysdesignprep.com, nickname "SysDesignPrep.com", uploader_id 6748570570327426053, and the audio is "original sound - SysDesignPrep.com". The description is 266 characters long and links nothing, so no links were staged (links.json does not exist). It ends with "Full Design Ticketmaster breakdown at SysDesignPrep.com" and five hashtags. Engagement at capture (2026-11-17 13:01:22 UTC, about 8 hours after posting) was 242 views, 14 likes, 0 comments, 0 reposts, 4 saves. I read 7 frames: 001, 005, 010, 015, 020, 025 and 029, at roughly 0 s, 8 s, 18 s, 28 s, 38 s, 48 s and 56 s. Every frame has a "SysDesignPrep.com" logo header and a green pill reading "DESIGN TICKETMASTER · HOW A SEAT IS HELD". Frame 001 shows the title "6 clicks / 1 seat" over a seat map labelled "STAGE", a highlighted seat "A-12-3" with several coloured cursors on it, and the word-by-word caption "40 people". Frame 005 shows "THE TEMPTING ANSWER", a padlock and "Distributed lock", with caption "a distributed lock." Frame 010 adds "Redis" and "ZooKeeper" chips, a "Lock service (owner: buyer A)" box and an "Inventory DB (A-12-3: available)" box joined by "must agree", and a timeline where Buyer A has "lock ✓", then "GC pause" across a "lock TTL ends" line, then "write: SOLD", while Buyer B goes from "waiting" to "lock ✓" to "write: SOLD", all under a red "SOLD TWICE" stamp. Frame 015 shows a grid of 40 chips numbered #01 to #40, with caption "First request". Frame 020 shows a code card "409 Conflict POST /v1/holds" with JSON {"error": "seat_taken", "taken": ["A-12-3"], "suggested": ["A-12-9", "A-13-3"]}, with caption "Losers". Frame 025 shows "A HOLD IS A LEASE" with a card seat_id A-12-9, status held, hold_id h_91, expires_at 10:04:12, a 4:47 countdown ring and a struck-through "tab closed" chip, with caption "so abandoned". Frame 029 is an end card for "Design Ticketmaster: Sell 60 000 seats in ten minutes to a million people at once, and never sell one twice," tagged "Step-by-step walkthrough", "5 deep dives" and "5 request flows". No frame I read shows the SQL statement itself, a terminal, a benchmark or any measured result. The transcript has 24 lines in 24 segments (about 150 words). Its argument is that a distributed lock needs two systems to agree and can fail when a lock expires during a garbage collection pause, whereas one conditional UPDATE lets the database pick exactly one winner, with a 409 and suggested seats for the losers and a hold that expires by itself. Transcript check: the last genuine segment (id 18, "The whole design is on sysdesignprep.com.") ends at 57.46 s, inside the 59.71 s audio. Segments 19 to 23 ("Thank you very much for joining us.", "Let's get started.", "Thank you.", "Thanks.", "Thank you.") start at 58.10 s and run to 61.46 s. They were decoded at temperature 1.0 with avg_logprob -2.05, and the last four start at or after 59.06 s, with the final three beginning past the 59.71 s end of audio. I treat all five as hallucinated and do not use them.**

## The lock-expiry failure is real, but the video's version is simplified

At 10.82 s the video says "But now, two systems have to agree," and at 16.18 s it says "If the lock expires during a garbage collection pause, a second buyer grabs it and the seat sells twice." Frame 010 draws this as a timeline: Buyer A holds the lock, a GC pause crosses the TTL, Buyer B takes the lock, and both write SOLD. This matches the failure mode in Martin Kleppmann's essay on distributed locking. He describes a client paused by a stop-the-world GC for longer than its lease, which still believes it holds the lock and writes after another client has acquired it. He also notes that checking the lease right before the write does not close the gap, because the pause can fall between the check and the write.

The video leaves out the standard remedy. Kleppmann's fix is a fencing token: the lock service issues a number that increases on each acquisition, and the storage layer rejects writes carrying a token lower than one it has already seen. He says Redlock does not produce such tokens. So the claim "the seat sells twice" is true of a lock that gates writes without fencing, but a lock with fencing does not have that flaw. The video's own frame 010 shows the weakness as "lock service" and "Inventory DB" having to agree, and the fencing token is the mechanism that makes the database the final arbiter. That is close to the video's conclusion: the database check carries the correctness. The video presents lock-plus-fencing as non-existent when it is a known pattern, though it adds a second system that the conditional UPDATE does not need.

## The conditional UPDATE does give one winner, with a caveat on the claim "no retry loop"

At 24.24 s the video says "Mark the seat held, but only where its status is still available," then at 30.14 s "The first request matches one row," at 33.32 s "The other 39 match zero rows," and at 37.74 s "The where clause is the lock." The clip never shows the SQL, so the exact statement is not visible in any frame I read. The behaviour described is consistent with the PostgreSQL documentation on Read Committed isolation. When a second updater reaches a row that a concurrent transaction has already changed, it waits for that transaction to finish. If the first committed an update, the second re-evaluates its WHERE clause against the new row version, and if the row no longer matches, the row is skipped. For a statement like "set status to held where seat_id is X and status is available", the first transaction flips the status and the others, after waiting, find zero matching rows. The affected-row count then tells each caller whether it won. This verifies the mechanism for PostgreSQL. I did not check MySQL, DynamoDB or other stores, and the video does not name a database. The video's "40 people" and "39 match zero rows" arithmetic is a worked example, not a measurement.

"No lock service, no retry loop" is accurate for the winner and loser paths as described. Losers do not loop on the server. Row-level locking still happens inside the database during the UPDATE, so the database takes a lock internally. The video's phrase "the where clause is the lock" is a figure of speech: the database's row lock plus the predicate re-check provides the exclusion, and the application needs no separate lock service. A multi-seat purchase (several seats in one request) would need all-or-nothing handling that the clip does not address. Frame 020's JSON "taken" array is a list, which hints at multi-seat requests, but the video does not explain how partial failures are handled.

## The 409 response and the "refreshing 30 times" claim

At 41.8 s the video says "Losers get an instant 409 with free seats nearby," and at 44.96 s "so they try once instead of refreshing 30 times." Frame 020 shows "409 Conflict POST /v1/holds" with a body naming the taken seat and two suggested seats (A-12-9, A-13-3). The MDN reference describes 409 as a request that conflicts with the current state of the target resource, which the client can often fix and resubmit. A taken seat fits that definition. Returning suggestions with the error is a product design choice, and I found no source that measures its effect. The "30 times" figure has no source in the video or the description and appears to be an illustrative number. I mark it Unverified. The claim that suggestions reduce refresh behaviour is plausible but untested in anything I read.

## Holds with their own expiry, and what the Design Ticketmaster page contains

At 47.8 s the video says "the hold carries its own expiry, so an abandoned tab gives the seat back." Frame 025 shows a row with status held, hold_id h_91, expires_at 10:04:12 and a 4:47 countdown. The card title "A HOLD IS A LEASE" describes the pattern of a time-bounded claim stored with the data. The clip does not say how the seat returns to "available" once expires_at passes. One option is a background sweeper, and another is a read-time check that treats an expired hold as available. The video states neither, so the mechanism is not specified. The 4:47 value is an on-screen display, and no source gives the real hold length for any ticketing site. The video also does not say that the described design is Ticketmaster's. It is the channel's own "Design Ticketmaster" interview answer, per the end card in frame 029. The end card's "Sell 60 000 seats in ten minutes to a million people at once" is a scenario the site poses, not a reported Ticketmaster figure.

The video sends viewers to sysdesignprep.com. I fetched the home page, which says the site lists 86 questions but did not show a Design Ticketmaster page or any detail on seat holds or pricing in the content returned. I could not confirm what the full breakdown contains, how many deep dives it has beyond the end card's "5 deep dives," or whether access is free or paid. I did not fetch any tiktok.com page.

## Key Takeaways

- **Verified:** A client paused past its lock lease can write after another client takes the lock, which is the "sold twice" scenario at 16.18 s. Kleppmann's essay describes the same GC-pause failure.
- **Verified:** In PostgreSQL Read Committed, a second concurrent UPDATE waits, then re-checks its WHERE clause against the committed row and skips it if it no longer matches, so one conditional UPDATE yields one winner.
- **Partial correction:** The video implies the lock approach has no fix. Kleppmann's fencing tokens let the storage layer reject stale writers, though the video's point that a single database check is simpler holds.
- **Clarification:** "The where clause is the lock" is a figure of speech. The database still takes a row lock internally, and the SQL never appears in the frames I read.
- **Unverified:** "refreshing 30 times," the 4:47 hold timer and the 60,000-seat scenario have no source. The expiry mechanism is not described in the clip.
- **Context:** The final five transcript segments (58.10 s onward, including "Let's get started.") are Whisper invention, and the end-card page could not be confirmed on sysdesignprep.com.

## Resources

- [How to do distributed locking, Martin Kleppmann, 2016-02-08](https://martin.kleppmann.com/2016/02/08/how-to-do-distributed-locking.html) establishes the GC-pause lease-expiry failure and the fencing-token remedy I cite.
- [Transaction Isolation, PostgreSQL documentation](https://www.postgresql.org/docs/current/transaction-iso.html) establishes Read Committed behaviour for concurrent UPDATE with WHERE re-evaluation.
- [409 Conflict, MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/409) establishes the meaning of HTTP 409.
- [SysDesignPrep.com home page](https://sysdesignprep.com) establishes that the site lists 86 questions; it did not show the Ticketmaster page in the content I received.
