Optimistic Locking Is Everywhere. You Just Don’t Recognize It.
Ask a developer if they use optimistic locking and you’ll likely get a shrug. Ask them if they’ve ever added a @Version annotation, written a conditional UPDATE, or debugged a DynamoDB ConditionalCheckFailedException, and suddenly the picture changes.
The gap between “textbook optimistic locking” and what actually ships to production is a chasm. But it’s not the chasm most people assume. The reality is messier, more distributed, and honestly, more interesting than “nobody uses it.”
The Version Column Is the Workhorse
How common is optimistic locking in real production systems? The top answer cut through the noise with a rule of thumb that’s worth tattooing on every developer’s forearm:
“If the write is ‘read, decide, write back’ and a wrong result costs money, it gets a version check or a conditional update. Everything else stays last-write-wins.”
That’s not laziness. That’s economics.
In practice, optimistic locking shows up in three primary forms, and only one of them gets the name:
1. ORM version columns. Hibernate’s @Version, Rails’ lock_version, EF’s rowversion. One annotation. Teams add it to the handful of entities where two humans genuinely edit the same record, orders, back-office forms, shared schedules. Nowhere else.
2. Conditional updates that nobody calls optimistic locking. This is the stealthiest form. Writing UPDATE orders SET status = 'paid' WHERE id = ? AND status = 'pending' and checking the affected row count is optimistic locking. The state field is the version. This pattern is everywhere, and most engineers writing it don’t think twice about what it’s called.
3. Datastore-native primitives. DynamoDB conditional writes, Elasticsearch’s if_seq_no, Kubernetes’ resourceVersion. These are optimistic locking with the serial numbers filed off, baked into infrastructure that forces you into the pattern by design.
The split consistently lands at: a few critical records get protection, everything else runs on vibes.
The ETag Problem: Why the HTTP Layer Stays Bare
Here’s where the theory really diverges from practice. ETag + If-Match over HTTP, the canonical textbook example, is almost nowhere in production.
The reason isn’t technical. It’s a collaboration problem.
ETags require the client to participate. The frontend has to store the ETag, send it back, and handle the 409 Conflict response. In practice:
- Most frontends just send the whole form back without tracking versions.
- Public APIs adopt ETags because providers can’t trust third-party clients to behave.
- Internal CRUD apps skip it entirely because the client is a React SPA that would need coordinated changes across the entire stack.
There’s a deeper issue lurking here. Deciding what the user sees on a conflict is a product decision, not an engineering one. “Latest wins, keep the old value in history” is fine for most fields. But quantities? Notes? Medical records? That’s when you need merge semantics or a UI for showing both versions, and that’s where the real work lives.
Mobile Apps Are the Silent Champions
The place optimistic locking actually dominates is mobile apps with offline edits. It just doesn’t wear the name.
The mobile client keeps the version it last saw for each record. When a sync happens after being offline overnight, the server rejects or merges changes when versions don’t match. Without this pattern, two devices that were offline quietly overwrite each other, and nobody notices until a customer calls to ask why their reservation vanished.
This is a production-grade example of why the transactional outbox and consistency in distributed updates conversation matters. These systems are running optimistic concurrency at massive scale, and the developers building them would never describe their job that way.
The Production Data That Tells the Real Story
You want hard numbers? Here’s a real one, straight from a production issue logged on November 27, 2026, in the StelLight API repository:
“In production history, 304 updates overwrote a change that another user had saved shortly before (within 5 minutes), by sending the values from before that change: 61 of them in the last 90 days (about 1.1% of updates).”
Let’s unpack that. The system was running last-write-wins. In the last 90 days, 61 updates silently destroyed another user’s work. The fix: add a version field (JPA @Version), return it in responses, reject updates with outdated versions via a 409, and let clients handle the conflict intelligently.
But here’s the kicker, the issue notes that 86% of quick consecutive edits were fine. The later editor had already seen the earlier change. Only the remaining 14% were true overwrites. That’s why this pattern isn’t applied universally. The cost-benefit analysis says: accept the risk on most records, protect the ones where loss is expensive.
For the record, the expected impact was “about 0.7 rejected updates a day”, each of which would otherwise have silently destroyed someone’s work. That’s the cost of doing nothing.
The same calculus applies to aggregate design and transactional boundaries affecting concurrency control. Your aggregate boundaries determine what needs protection and where the version columns live. Getting this right is an architectural decision, not a checkbox.
When the Infrastructure Forces Your Hand
Real-world optimistic locking also gets pushed into existence by infrastructure that refuses to allow anything else.
A recent issue on the tierstore project describes implementing If-Match on PutObject and CompleteMultipartUpload as a compare-and-swap over the markers. The semantics are brutal and precise:
PUT kwithIf-Match: <etag>→ 200, new bytes storedPUT kwithIf-Match: "other"→ 412, bytes unchangedPUT kwithIf-Matchon an absent key → 404 NoSuchKey- Race condition → 409 ConditionalRequestConflict
This is object storage doing optimistic locking at the protocol level because the alternative, allowing blind overwrites, is unacceptable for a storage system.
Then there’s the ETag edge case that keeps infrastructure engineers up at night. A SeaweedFS issue describes how weak ETags (W/"...") from nginx compression break If-None-Match revalidation:
curl -s -o /dev/null -w '%{http_code}\n' -H 'If-None-Match: "5eb63bbbe01eeed093cb22bb8f5acdc3"' localhost:8333/bkt/obj # 304
curl -s -o /dev/null -w '%{http_code}\n' -H 'If-None-Match: W/"5eb63bbbe01eeed093cb22bb8f5acdc3"' localhost:8333/bkt/obj # 200, expected 304
Every revalidation downloads the full object. The etagMatches function only trims quotes and splits on commas, so W/"abc" becomes W/"abc and never matches. The fix requires RFC 9110 §13.1.2 weak comparison semantics, a deep rabbit hole that only matters because optimistic locking is actually in use.
The New Frontier: Multi-Agent Systems
The most interesting recent adoption of optimistic locking isn’t in traditional CRUD at all. It’s in AI agent systems where multiple agents share workflow state.
Hemapriya Kanagala’s multi-agent system on AWS demonstrates this beautifully. She built a customer support system with five agents (Orchestrator, Inventory, Policy, Refund, Communication) sharing a DynamoDB-backed WorkflowState. The version field wasn’t optional, it was essential:
“Imagine two operations reading the same WorkflowState record at almost the same time. Both read version 1. The first operation updates successfully, and its version becomes 2. But the second operation is still working with the older version 1. If the second operation saves without checking the version, it could overwrite an update made by the first operation.”
Her implementation: check the version, update if it matches, increment it. On conflict, re-read the latest state and retry, up to three attempts. Classic optimistic locking with retry semantics.
The parallel retrieval using ThreadPoolExecutor made concurrent writes an inevitability, not a corner case. Most tutorials skip concurrent writes entirely, which means they ship applications that will corrupt their own state the moment agents run in parallel. (Her project scored 120/120, but the real win was understanding why optimistic locking mattered.)
The pattern extends well beyond AWS. Kubernetes’ resourceVersion is the same idea. Any system where event-driven architectures and read model consistency matter has to answer this question.
The Messy Middle: Where Optimistic Locking Actually Lives
The real story of optimistic locking adoption isn’t “everyone uses it” or “nobody uses it.” It’s a targeted deployment strategy:
Where it’s everywhere:
– Public APIs (untracked clients you can’t trust)
– Mobile apps with offline sync (the entire offline-first model depends on it)
– Storage infrastructure (object stores, databases, Kubernetes)
– AI agent workflows (multiple agents sharing state)
Where it’s nowhere:
– Internal CRUD apps (where the risk is “two people edit the same row within seconds”, rare enough to ignore)
– Most web frontends (where clients refuse to carry version numbers)
– Back-office forms (until the first incident, anyway)
The trigger for adoption is almost always one of three things:
- A production incident where data is silently lost
- Platform infrastructure that forces the pattern
- A wrong result that costs real money (inventory, balances, anything a background job and a human both touch)
If you’re building a system where any of those conditions apply, client-side state management and optimistic concurrency in UIs becomes essential reading. Linear’s approach to optimistic UI updates shows how far you can take this pattern when your architecture embraces it.
The Bottom Line
Optimistic locking is not a theoretical construct gathering dust in textbooks. It’s alive in every conditional write, every version annotation, every ETag comparison, every DynamoDB condition expression. The adoption is patchy and uneven, not because engineers don’t care, but because the cost-benefit analysis often says last-write-wins is good enough.
Until it isn’t.
The 1.1% of updates that silently destroyed another user’s work in the StelLight production history is the price of that calculus. The question isn’t whether you can afford optimistic locking. It’s whether you can afford the alternative.
The safest approach: start with version columns on every entity that two humans or two agents could plausibly edit. Add conditional updates where state transitions matter (status changes, payment flows). Implement proper conflict resolution UIs where product logic demands it. Skip it everywhere else, but know why you’re skipping it.
That’s not theory. That’s practice.
