<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/concurrency-control-arbitration-vs-serialization-gdw9qm0rj" -->

---
title: Concurrency Control: Arbitration vs. Serialization
description: Concurrency control splits into two distinct mechanisms: arbitration (allows concurrent access, rejects the loser via compare-and-swap, expected revision, or...
canonical: https://daily.dev/posts/concurrency-control-arbitration-vs-serialization-gdw9qm0rj
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Concurrency Control: Arbitration vs. Serialization | daily.dev
og:description: Concurrency control splits into two distinct mechanisms: arbitration (allows concurrent access, rejects the loser via compare-and-swap, expected revision, or...
og:url: https://daily.dev/posts/concurrency-control-arbitration-vs-serialization-gdw9qm0rj
og:image: https://api.daily.dev/og/posts/GDW9qM0rJ.png
og:image:alt: Concurrency Control: Arbitration vs. Serialization
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.

# Concurrency Control: Arbitration vs. Serialization

**[Atomic Spin](https://daily.dev/sources/atomicobject)** · 16 min read · 30 upvotes · 4 comments

## Summary

Concurrency control splits into two distinct mechanisms: arbitration (allows concurrent access, rejects the loser via compare-and-swap, expected revision, or unique constraints) and serialization (prevents concurrent access via locks, leases, or leaders). Arbitration is total and survives partitions, unreachable coordinators, and forgotten locks; serialization is conditional and quietly evaporates when a writer fails to participate or the coordinator is unreachable. The guidance is to put correctness on the arbiter and performance on the serializer. This principle is applied to a NestJS CQRS backend on KurrentDB and Postgres, covering per-entity serialization via Postgres advisory locks, deriving entity IDs from natural keys to sidestep coordination problems (with strict requirements: deterministic, injective, and stable under normalization drift), achieving exactly-once effects by committing an offset and its effect atomically in one transaction, and using SKIP LOCKED as a short-lived work-distribution hint rather than a correctness guarantee for scheduled jobs.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://spin.atomicobject.com/concurrency-control-serialization>

## Questions this post answers

### What is the difference between arbitration and serialization for concurrency control in distributed systems?

Serialization prevents concurrent access entirely using mechanisms like mutexes, leases, leader election, or locks, but it only holds when every writer agrees to participate and the coordinator stays reachable. Arbitration permits concurrent access and rejects the loser using compare-and-swap, expected stream revisions, or unique constraints, and it is total: it holds during partitions, unreachable coordination services, and forgotten locks because it is evaluated at the moment of write. Correctness should rest on arbitration; serialization should only be used for performance.

_daily.dev surfaces deep dives like this for engineers weighing lock-based versus optimistic concurrency strategies._

### How do you achieve exactly-once processing when consuming events with at-least-once delivery semantics?

Exactly-once effect equals at-least-once delivery plus an atomic commit of the effect and a dedup marker in the same transaction. For a projection writing into the same Postgres database, wrapping the event handler and the offset update inside one database transaction guarantees this; separating those two writes creates a window where redelivery applies the event twice. Effects outside that transaction boundary, like sending email or calling a third-party API, can never be exactly-once regardless of retry logic.

_Engineers designing event-driven projections rely on daily.dev to track patterns like transactional offset commits._

### How do I generate a stable, collision-free entity ID from a natural key like an organization and a set of device serial numbers?

Derive the ID deterministically using uuidv5 over a namespace constant plus the organization ID and a normalized, sorted list of serial numbers, JSON-encoding the array rather than joining with a separator to stay injective. The sort must use a locale-independent code-point comparator, not localeCompare, since a default-locale sort produces different orderings across runtimes. Because the derivation is frozen once entities exist in an event store, it must be deterministic, injective, and stable under normalization drift from the very first write.

_daily.dev helps developers designing deterministic ID schemes for event-sourced entities stay ahead of naming pitfalls._

## Community discussion

Top comments from developers on daily.dev.

**@trevorsuna** · 2 upvotes

> The distinction between arbitration for correctness and serialization for efficiency is useful. A lock can reduce collisions, but the transaction or unique constraint still needs to settle the winner when a worker crashes or misses the lock. The SKIP LOCKED example makes that boundary especially clear.

**@agustinbarrientos** · 1 upvotes

> I think the single-threaded Node example needs a correction. Two requests can interleave at an await, even in one process. I'd test this by pausing both requests after the read.

**@ristotoldsep** · 0 upvotes

> A database constraint is worth a lot of 'this should never happen' comments.

## Similar posts on daily.dev

- [Your Database’s Isolation Levels Don’t Mean What You Think – Master.dev Blog](https://daily.dev/posts/your-database-s-isolation-levels-don-t-mean-what-you-think-master-dev-blog-1aek2w6i3) · Frontend Masters · 0 upvotes · 0 comments
- [Optimizing Search Performance with CQRS: Relational Writes and NoSQL Reads](https://daily.dev/posts/optimizing-search-performance-with-cqrs-relational-writes-and-nosql-reads-3zldezxon) · Sergio Lema · 9 upvotes · 0 comments
- [Handling Race Conditions in Multi-Agent Orchestration](https://daily.dev/posts/handling-race-conditions-in-multi-agent-orchestration-ubkdtwbac) · Machine Learning Mastery · 4 upvotes · 0 comments
- [The multiform read-write separation](https://daily.dev/posts/the-multiform-read-write-separation-09ftiubyw) · ITNEXT · 4 upvotes · 0 comments

---

Tags: [#architecture](https://daily.dev/tags/architecture), [#postgresql](https://daily.dev/tags/postgresql), [#distributed-systems](https://daily.dev/tags/distributed-systems), [#nestjs](https://daily.dev/tags/nestjs)

[View this post on daily.dev](https://daily.dev/posts/concurrency-control-arbitration-vs-serialization-gdw9qm0rj)

```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":"Concurrency Control: Arbitration vs. Serialization","url":"https://daily.dev/posts/concurrency-control-arbitration-vs-serialization-gdw9qm0rj","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/concurrency-control-arbitration-vs-serialization-gdw9qm0rj"},"datePublished":"2026-09-21T12:11:49.797Z","dateModified":"2026-09-21T12:12:27.230Z","description":"Concurrency control splits into two distinct mechanisms: arbitration (allows concurrent access, rejects the loser via compare-and-swap, expected revision, or...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/f9033944a0ff6614a4a9caea1b1d27d6?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/f9033944a0ff6614a4a9caea1b1d27d6?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Atomic Spin","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":"Atomic Spin","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/e2af5ce3adaa403a8cf029268b62419f","url":"https://daily.dev/sources/atomicobject"},"commentCount":4,"discussionUrl":"https://daily.dev/posts/concurrency-control-arbitration-vs-serialization-gdw9qm0rj","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":30},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":4}],"keywords":"architecture,postgresql,distributed-systems,nestjs","timeRequired":"PT16M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Atomic Spin","item":"https://daily.dev/sources/atomicobject"},{"@type":"ListItem","position":3,"name":"Concurrency Control: Arbitration vs. Serialization"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/concurrency-control-arbitration-vs-serialization-gdw9qm0rj","comment":[{"@type":"Comment","text":"The distinction between arbitration for correctness and serialization for efficiency is useful. A lock can reduce collisions, but the transaction or unique constraint still needs to settle the winner when a worker crashes or misses the lock. The SKIP LOCKED example makes that boundary especially clear.","datePublished":"2026-09-22T02:36:22.681Z","url":"https://daily.dev/posts/GDW9qM0rJ#c-cYjaa0cMf","author":{"@type":"Person","name":"Trevor Suna","url":"https://daily.dev/trevorsuna","image":"https://media.daily.dev/image/upload/s--dZ7gXxpp--/f_auto/v1784081551/avatars/avatar_EMoP47rpuw8DNjhp6R1b6?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"I think the single-threaded Node example needs a correction. Two requests can interleave at an await, even in one process. I’d test this by pausing both requests after the read.","datePublished":"2026-09-23T03:10:51.446Z","url":"https://daily.dev/posts/GDW9qM0rJ#c-UH8BCKUsn","author":{"@type":"Person","name":"Agustin Barrientos","url":"https://daily.dev/agustinbarrientos","image":"https://media.daily.dev/image/upload/s--5ayxQnqn--/f_auto/v1788281802/avatars/avatar_wQYYVe5Tbj0NJ7C7qPoa8?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"A database constraint is worth a lot of ‘this should never happen’ comments.","datePublished":"2026-09-23T14:17:42.951Z","url":"https://daily.dev/posts/GDW9qM0rJ#c-5beWHjVN7","author":{"@type":"Person","name":"Risto Tõldsep","url":"https://daily.dev/ristotoldsep","image":"https://media.daily.dev/image/upload/s--i6RRoxB7--/f_auto,pg_1/v1794383659/avatars/avatar_ryDlbifZ1EuRuh3g51ryC?_a=BAMAMiiw0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/concurrency-control-arbitration-vs-serialization-gdw9qm0rj#faq","mainEntity":[{"@type":"Question","name":"What is the difference between arbitration and serialization for concurrency control in distributed systems?","acceptedAnswer":{"@type":"Answer","text":"Serialization prevents concurrent access entirely using mechanisms like mutexes, leases, leader election, or locks, but it only holds when every writer agrees to participate and the coordinator stays reachable. Arbitration permits concurrent access and rejects the loser using compare-and-swap, expected stream revisions, or unique constraints, and it is total: it holds during partitions, unreachable coordination services, and forgotten locks because it is evaluated at the moment of write. Correctness should rest on arbitration; serialization should only be used for performance. daily.dev surfaces deep dives like this for engineers weighing lock-based versus optimistic concurrency strategies."}},{"@type":"Question","name":"How do you achieve exactly-once processing when consuming events with at-least-once delivery semantics?","acceptedAnswer":{"@type":"Answer","text":"Exactly-once effect equals at-least-once delivery plus an atomic commit of the effect and a dedup marker in the same transaction. For a projection writing into the same Postgres database, wrapping the event handler and the offset update inside one database transaction guarantees this; separating those two writes creates a window where redelivery applies the event twice. Effects outside that transaction boundary, like sending email or calling a third-party API, can never be exactly-once regardless of retry logic. Engineers designing event-driven projections rely on daily.dev to track patterns like transactional offset commits."}},{"@type":"Question","name":"How do I generate a stable, collision-free entity ID from a natural key like an organization and a set of device serial numbers?","acceptedAnswer":{"@type":"Answer","text":"Derive the ID deterministically using uuidv5 over a namespace constant plus the organization ID and a normalized, sorted list of serial numbers, JSON-encoding the array rather than joining with a separator to stay injective. The sort must use a locale-independent code-point comparator, not localeCompare, since a default-locale sort produces different orderings across runtimes. Because the derivation is frozen once entities exist in an event store, it must be deterministic, injective, and stable under normalization drift from the very first write. daily.dev helps developers designing deterministic ID schemes for event-sourced entities stay ahead of naming pitfalls."}}]}
```

