Reservation lab

One parking space. Two phones. Ada and Ben have different request IDs. Choose who sends first, then inspect what committed.

Who gets the last space?

A claim is a stored record saying who owns the reservation. A transaction groups the claim and the counter change so that both take effect together. Predict both the free count and the number of claims after two calls.

Ready to race.
What ran on my device?

Two connections to a temporary IndexedDB database each open a read-write transaction over the inventory and claims stores. Their overlapping writes are serialized by the browser. Inspect the final state below after each run. PostgreSQL uses a different locking mechanism, explored in the isolation exercise.

Return to lesson · Conditional writes

What if the reply disappears?

Ada sends a request, loses the response and tries again. There are two spaces here so a second charge against inventory is visible. Choose where the interruption happens and which identity the second call uses.

Ready to send.

Return to lesson · Retry identity

Follow two PostgreSQL connections

Step through a model of four schedules verified on PostgreSQL 17.6. Before each step, predict what an independent reader can see. Each run begins with a fresh fixture.

Run the same schedules on a database server

The Python fixture opens three PostgreSQL connections, checks the blocking connection and verifies the final records. The setup and adjacent-seat challenge and Python runner are available here.

Advanced lab · Promote a real PostgreSQL standby

Which confirmations survive the loss of a primary? In this local lab, grant 41 waits for replay on a named standby. Grant 42 receives a local acknowledgement while that standby is offline. Predict the row IDs a new writer will contain. The runner starts two disposable PostgreSQL servers, stops the original writer, promotes the copy and queries it.

Use PostgreSQL 17 server tools on PATH and a Python environment with psycopg installed. Run python failover.py as an ordinary user. Compare the successful client replies with the surviving IDs. Explain why routing a later read to the new primary cannot recreate a missing grant.

Download the two-server experiment · Setup and worked review

Return to lesson · Conditional writes

When does the queue drain?

A queue holds requests waiting for service. Choose whole requests per second. Run one minute of peak traffic followed by one minute of recovery. A queue limit of zero drops all work beyond the current second's capacity.

Ready to simulate.
Check your reasoning

At 120 arrivals and 100 completions per second, the backlog grows by 20 each second. In 60 seconds that makes 1,200. Recovery at 80 arrivals frees 20 slots per second. Raise recovery arrivals to 100 and see why returning traffic to capacity leaves the backlog in place.

Return to lesson · Overload

Can a receipt survive a worker crash?

Ada's grant and pending event 41 commit together. A worker consumes that event and increments the local receipt count. Choose how it records consumption, then interrupt the first delivery. Predict the final count before running the repair.

Ready to deliver event 41.
What evidence distinguishes loss from duplication?

The worker reconnects, reads the pending event and retries it. Exactly one grant should have exactly one receipt. A separately committed processed ID can suppress the missing receipt. A missing identity check lets a committed receipt repeat. All writes here use IndexedDB. Stopping between transactions and aborting an in-flight transaction model different crash boundaries. An external email provider would need its own delivery contract.

Return to lesson · Transactional outbox