# Inside TursoDB MVCC: Concurrent Writes and Async io_uring Explained

> A practical breakdown of how TursoDB replaces SQLite's single-writer lock with optimistic MVCC transactions and non-blocking Linux io_uring pipelines.
> Published: 2026-11-22
> Canonical URL: https://tursodb.cn/blog/mvcc-concurrent-writes-io-uring/
> Source: TursoDB.cn Independent Developer Community

If you have ever scaled SQLite in production, you know the dreaded `SQLITE_BUSY` error. Even with `PRAGMA journal_mode = WAL` and generous `busy_timeout` values, SQLite fundamentally allows only **one writer at a time**.

## What Happens in Classic WAL Mode?

In standard SQLite WAL mode:
- Multiple readers run concurrently without blocking writers.
- However, once Connection A executes an `INSERT` or `UPDATE`, it acquires the single write lock until `COMMIT`.
- Connection B, trying to update a completely unrelated table, must spin or fail with `SQLITE_BUSY`.

## How TursoDB MVCC Solves It

TursoDB introduces **Multi-Version Concurrency Control (MVCC)** activated via `BEGIN CONCURRENT`:

1. **Snapshot Isolation**: Each transaction reads a consistent version of rows as of its start timestamp.
2. **Parallel Buffering**: Writers append new row versions without locking the entire database file.
3. **Commit-Time Validation**: At `COMMIT`, the engine checks whether another committed transaction modified the same rows or index keys. Disjoint writes commit immediately; conflicting writes return a clean retryable error.

```sql
BEGIN CONCURRENT;
INSERT INTO telemetry_events (service, latency_ms) VALUES ('edge-eu', 14);
COMMIT;
```

## Why `io_uring` Matters Alongside MVCC

Concurrency in the transaction layer only reaches its full potential when storage I/O doesn't stall OS worker threads. By submitting batched read/write SQEs through Linux `io_uring`, TursoDB keeps CPU utilization predictable and tail latencies tight even when hundreds of lightweight databases flush simultaneously on a single node.
