Download README.md from DataDrivenAlex/concurrency-control-lab: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/spaces/DataDrivenAlex/concurrency-control-lab/resolve/main/README.md
- Command line
-
hf download hf://spaces/DataDrivenAlex/concurrency-control-lab/README.md
-
curl -L -o README.md https://huggingface.co/spaces/DataDrivenAlex/concurrency-control-lab/resolve/main/README.md
title: Concurrency Control Lab
emoji: 🔀
colorFrom: blue
colorTo: indigo
sdk: static
pinned: false
Concurrency Control Lab
A hands-on simulator for a classic backend bug: two requests read the same record version, then overwrite each other's updates. Compare last-write-wins with optimistic locking and see when a retry preserves the intended edits.
Try the demo
Open the Space and change the initial value, client edits, commit order, or conflict-retry setting. The demo shows the version checks, accepted writes, conflicts, retries, and final value. The example is deterministic so the same request schedule always produces the same trace.
Run the Python model
python -m unittest -v
engine.py models a set of edits that all read one initial snapshot. Last-write-wins commits each stale computed value, illustrating lost updates. Optimistic locking accepts a write only when its base version matches the current version; a stale write is rejected, and an optional retry re-reads and recomputes against the latest value.
Scope and limitations
This is an educational, in-memory simulation, not a database benchmark or production concurrency library. It assumes integer deltas, a single record, a deterministic commit order, and no network failures. Real systems must define transaction isolation, retry limits/backoff, idempotency, validation, and user-facing conflict behavior for their database and workload. The browser demo is static and does not call a backend or persist data.