<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/why-optimistic-locking-in-ledgers-isn-t-always-a-good-idea-o8cl8lh1z" -->

---
title: Why Optimistic Locking in Ledgers Isn’t Always a Good Idea
description: Ledger systems must be correct in two senses: producing accurate financial statements and gatekeeping which transactions are allowed in. Version locking...
canonical: https://daily.dev/posts/why-optimistic-locking-in-ledgers-isn-t-always-a-good-idea-o8cl8lh1z
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Why Optimistic Locking in Ledgers Isn’t Always a Good Idea | daily.dev
og:description: Ledger systems must be correct in two senses: producing accurate financial statements and gatekeeping which transactions are allowed in. Version locking...
og:url: https://daily.dev/posts/why-optimistic-locking-in-ledgers-isn-t-always-a-good-idea-o8cl8lh1z
og:image: https://api.daily.dev/og/posts/o8cl8LH1Z.png
og:image:alt: Why Optimistic Locking in Ledgers Isn’t Always a Good Idea
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Why Optimistic Locking in Ledgers Isn’t Always a Good Idea

**[The PayEng Playbook](https://daily.dev/sources/alvaroduran)** · 6 min read · 1 upvotes · 0 comments

## Summary

Ledger systems must be correct in two senses: producing accurate financial statements and gatekeeping which transactions are allowed in. Version locking (tracking an account_version on entries, distinct from same-table optimistic locking) is a common way payments engineers prevent double-spend race conditions, but it causes thread contention on frequently updated accounts such as pools of funds. Accounts that don't need real-time balance checks are better served by end-of-day balance snapshots rather than forcing every write through strict version locking, and balance should not simply live as a column on the Account table since its use case determines where it should be stored.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://news.alvaroduran.com/p/why-optimistic-locking-in-ledgers>

## Questions this post answers

### Why does optimistic locking with an account version column cause high latency in ledger systems?

Because when an account is updated frequently, only one concurrent transaction can commit at a time against a given account version, forcing all competing transactions to retry after rejection. This thread contention increases overall latency, and it is especially wasteful for pool-of-funds accounts that receive constant top-ups and withdrawals but rarely need strict real-time balance enforcement.

_Engineers weighing locking strategies for high-throughput ledger accounts can find deeper payments architecture discussions on daily.dev._

### Should account balance be stored as a column on the Account table in a ledger system?

Not necessarily, because whether a balance needs to support real-time integrity checks or just periodic reporting determines where it should be stored. Accounts requiring real-time balance checks cannot tolerate any data integrity risk, while pool-of-funds accounts can safely rely on an end-of-day balance computed separately rather than a live column.

_Teams designing ledger data models can track patterns like this for financial systems on daily.dev._

## Similar posts on daily.dev

- [Assume that Manual Work in a Ledger Is Impossible](https://daily.dev/posts/assume-that-manual-work-in-a-ledger-is-impossible-d3lwzbjww) · The PayEng Playbook · 0 upvotes · 0 comments
- [Optimistic Locking vs Pessimistic Locking](https://daily.dev/posts/optimistic-locking-vs-pessimistic-locking-tnez3fjrn) · Towards Dev · 25 upvotes · 0 comments
- [Lost Updates in EF Core: Optimistic vs. Pessimistic Concurrency](https://daily.dev/posts/lost-updates-in-ef-core-optimistic-vs-pessimistic-concurrency-xmi3kzmrw) · Atomic Spin · 0 upvotes · 0 comments
- [You Don't Know What a Ledger is For](https://daily.dev/posts/you-don-t-know-what-a-ledger-is-for-zjdw8smrs) · The PayEng Playbook · 0 upvotes · 0 comments
- [We replaced our ledger with two functions](https://daily.dev/posts/we-replaced-our-ledger-with-two-functions-cgps66xxj) · Awesome Elixir · 15 upvotes · 1 comments

---

Tags: [#database](https://daily.dev/tags/database), [#fintech](https://daily.dev/tags/fintech)

[View this post on daily.dev](https://daily.dev/posts/why-optimistic-locking-in-ledgers-isn-t-always-a-good-idea-o8cl8lh1z)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Why Optimistic Locking in Ledgers Isn’t Always a Good Idea","url":"https://daily.dev/posts/why-optimistic-locking-in-ledgers-isn-t-always-a-good-idea-o8cl8lh1z","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/why-optimistic-locking-in-ledgers-isn-t-always-a-good-idea-o8cl8lh1z"},"datePublished":"2026-08-19T10:33:11.541Z","dateModified":"2026-09-13T20:09:39.028Z","description":"Ledger systems must be correct in two senses: producing accurate financial statements and gatekeeping which transactions are allowed in. Version locking...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/07a09d8d7dd1a2adbaf767450d6a86ca?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/07a09d8d7dd1a2adbaf767450d6a86ca?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"The PayEng Playbook","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"The PayEng Playbook","logo":"https://media.daily.dev/image/upload/s--F741aE6c--/f_auto/v1733559638/logos/alvaroduran","url":"https://daily.dev/sources/alvaroduran"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/why-optimistic-locking-in-ledgers-isn-t-always-a-good-idea-o8cl8lh1z","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"database,fintech","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"The PayEng Playbook","item":"https://daily.dev/sources/alvaroduran"},{"@type":"ListItem","position":3,"name":"Why Optimistic Locking in Ledgers Isn’t Always a Good Idea"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/why-optimistic-locking-in-ledgers-isn-t-always-a-good-idea-o8cl8lh1z#faq","mainEntity":[{"@type":"Question","name":"Why does optimistic locking with an account version column cause high latency in ledger systems?","acceptedAnswer":{"@type":"Answer","text":"Because when an account is updated frequently, only one concurrent transaction can commit at a time against a given account version, forcing all competing transactions to retry after rejection. This thread contention increases overall latency, and it is especially wasteful for pool-of-funds accounts that receive constant top-ups and withdrawals but rarely need strict real-time balance enforcement. Engineers weighing locking strategies for high-throughput ledger accounts can find deeper payments architecture discussions on daily.dev."}},{"@type":"Question","name":"Should account balance be stored as a column on the Account table in a ledger system?","acceptedAnswer":{"@type":"Answer","text":"Not necessarily, because whether a balance needs to support real-time integrity checks or just periodic reporting determines where it should be stored. Accounts requiring real-time balance checks cannot tolerate any data integrity risk, while pool-of-funds accounts can safely rely on an end-of-day balance computed separately rather than a live column. Teams designing ledger data models can track patterns like this for financial systems on daily.dev."}}]}
```

