~learn.
0:00 / 1:16
LLD · Online Auction

The auction ended. A bid a second later still got in.

transcript

The auction ended at 3,600. A bid arrives at 3,601. Trust only the closing timer, and it's accepted. The timer hadn't run yet.

Look at an auction's life. It opens when its start time passes. Bids keep it open. It sells, or goes unsold, when the end time passes. Three transitions, driven by time alone. Nobody clicked anything.

A timer closes due auctions every second. Trust it alone? Then a bid in that gap sees the state still open. And the late bid is accepted. Instead, every call checks the clock first. Closes the auction as of now. Then judges the bid.

The bid takes the auction's lock. First line: advance the state by the clock. The clock says it ended at 3,600. Closed, as of now. Then the bid is judged. Rejected.

The state said open only because nobody had looked. Advancing first closes it as of now. Timer or not.

The timer just notices deadlines when nobody calls. The clock, not the timer, decides when an auction ends.

Full breakdown in the lecture.