---
title: "An adventure in writing compatible systems"
description: "Turso, a Rust rewrite of SQLite, hit a bug where every write after the database crossed 1GB made SQLite's integrity checks fail, even though Turso's own checks found the file intact."
url: "https://swe.quest/articles/an-adventure-in-writing-compatible-systems-f48d37f87fc6e365"
canonical: "https://turso.tech/blog/an-adventure-in-writing-compatible-systems"
source: "Turso"
published: "2025-08-28"
difficulty: "medium"
kind: "Case study"
reading_minutes: 4
tags: ["sqlite","storage-engines","formal-methods","debugging","rust"]
---

# An adventure in writing compatible systems

A post on [Turso](https://swe.quest/sources/turso.md), published 2025-08-28, 4 min read, Case study. Original: [https://turso.tech/blog/an-adventure-in-writing-compatible-systems](https://turso.tech/blog/an-adventure-in-writing-compatible-systems)

## Summary

Turso, a Rust rewrite of SQLite, hit a bug where every write after the database crossed 1GB made SQLite's integrity checks fail, even though Turso's own checks found the file intact. The cause was the SQLite "pending byte" page: once a file passes the 1GB mark, SQLite reserves a special page tied to file locking, and Turso did not reserve it. The deterministic simulation tests had missed the bug because every profile injected faults, so no test database ever grew to 1GB. Adding fault-free runs fixed that gap, a reminder that compatible rewrites must match undocumented-feeling quirks of the original implementation.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [SQLite](https://swe.quest/tags/sqlite.md) (Data & databases)
- [Storage engines](https://swe.quest/tags/storage-engines.md) (Data & databases)
- [Formal methods](https://swe.quest/tags/formal-methods.md) (Architecture & design)
- [Debugging](https://swe.quest/tags/debugging.md) (Engineering practices)
- [Rust](https://swe.quest/tags/rust.md) (Languages)

## Prerequisites

- SQLite file format basics ([easy posts on SQLite](https://swe.quest/tags/sqlite.md?difficulty=easy))
- B-tree pages ([easy posts on Storage engines](https://swe.quest/tags/storage-engines.md?difficulty=easy))

## Keywords

Turso, SQLite, deterministic simulation testing, pending byte page

## Related posts

- [Introducing Limbo: A complete rewrite of SQLite in Rust](https://swe.quest/articles/introducing-limbo-a-complete-rewrite-of-sqlite-in-rust-eb77d828af295b26.md): Turso · 2024-12-10 · Easy · 7 min read · SQLite, Rust, Formal methods, Testing, WebAssembly
  Limbo is Turso's from-scratch rewrite of SQLite in Rust that aims for full language and file-format compatibility, memory safety and a modern architecture.
- [The final boss of reliability: formal verification](https://swe.quest/articles/the-final-boss-of-reliability-formal-verification-7d09556f91a9c3f0.md): Turso · 2026-07-07 · Medium · 6 min read · Formal methods, Testing, Storage engines, SQLite, Rust
  Turso, a from-scratch SQLite rewrite, is adding formal verification via Aretta AI's Aristo, which turns natural-language intents annotated on code into formally checked properties, to complement its deterministic simulation testing and Antithesis runs.
- [How we used Quint to find over 10 bugs in SQLite while hardening Turso](https://swe.quest/articles/how-we-used-quint-to-find-over-10-bugs-in-sqlite-while-hardening-turso-43686794db9fa980.md): Turso · 2026-05-18 · Medium · 5 min read · Formal methods, SQLite, Testing, Databases
  Modeling individual SQLite C API contracts in Quint, generating small traces, and replaying them as C programs against real SQLite uncovered more than 10 SQLite bugs while also validating Turso's compatible C API.
- [Turso v0.7.0](https://swe.quest/articles/turso-v0-7-0-8d3ff93b34352c14.md): Turso · 2026-07-13 · Hard · 10 min read · SQLite, Storage engines, Consistency models, Memory management, Rust
  Turso 0.7 drops the beta label and focuses on performance and robustness for embedded, multi-tenant use: the core no longer blocks on I/O, yields CPU via a new StepResult::Yield, moves to fallible allocation so OOM surfaces as an error, and treats the page cache as a soft limit like SQLite.
- [Beyond the Single-Writer Limitation with Turso's Concurrent Writes](https://swe.quest/articles/beyond-the-single-writer-limitation-with-turso-s-concurrent-writes-cb123f350ef5318c.md): Turso · 2025-10-06 · Hard · 12 min read · SQLite, Consistency models, Storage engines, Concurrency, Performance engineering
  Turso implements SQLite-compatible BEGIN CONCURRENT using Hekaton-style MVCC, which removes SQLite's single-writer bottleneck and the SQLITE\_BUSY errors that come with it.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
