Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Turso 5 min read Case study mediumAdept

How we used Quint to find over 10 bugs in SQLite while hardening Turso

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. Rather than specifying the whole database, each documented contract was modeled with only the state it needs, so a divergence points either to a model error or to a real bug. One example: sqlite3_deserialize() crashed instead of returning SQLITE_BUSY during an active read transaction. Other findings include wrong results from EXISTS-to-join and UPDATE planning optimizations, xfer optimization bypassing type and CHECK constraints, and mutex alignment undefined behaviour.

Related posts

  • An adventure in writing compatible systems

    Turso mediumAdept

    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.

  • Introducing Limbo: A complete rewrite of SQLite in Rust

    Turso easyNovice

    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 team chose a rewrite over the libSQL fork because invasive changes such as natural vector-index syntax and async I/O were hard to make in C without SQLite's proprietary test suite. Deterministic Simulation Testing is built in from the start, and Antithesis is used for system-level fault simulation, which has already caught io_uring partial-write bugs. Early results include a fully asynchronous sqlite3_step, a WASM-first build that works with Drizzle, fewer tunables, and a point query about 20% faster than tuned SQLite (506ns vs 620ns).

  • The final boss of reliability: formal verification

    Turso mediumAdept

    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. Aristo found in minutes a durability bug that DST had missed. When Turso acts as a sync replica of a cloud database, it bypasses the page cache, so pages became dirty without the dirty bit being set and were sometimes written to disk without fsync. The case for the approach is that properties like "a commit frame must be fsynced before being reported durable" are cheap to check formally. Runtime testing can miss them, because most runs happen to call fsync for unrelated reasons.

  • Carl Sverre ruined my day. And it was glorious

    Turso easyNovice

    Turso used Antithesis's new property-based testing library Hegel to check that its two TypeScript drivers, the native @tursodatabase/database and the pure-JS @tursodatabase/serverless, expose the same API and return identical results. With Claude setting up the harness, the first run found a bug within minutes. Expanding the generated inputs, such as adding RETURNING statements that stress serialization, surfaced four more edge-case bugs. Treating driver equivalence as a testable property gave the team enough confidence to start recommending the serverless driver over libSQL.

  • Turso v0.7.0

    Turso hardMaster

    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. The MVCC engine gets a linear-merge dual cursor that replaces per-row skiplist lookups (about a quarter of CPU time on write-heavy loads), watermark-driven garbage collection, experimental passive checkpoints that don't stop the world, and smaller row versions. SQL additions include PostgreSQL-style sequences (now backing AUTOINCREMENT), ICU collations, REINDEX, ordered-set aggregates and window-function groundwork. The SDKs gain a SQLite-compatible .NET/EF Core provider, GIL release and FTS in Python, and concurrent transactions in JavaScript.

The quest for software engineering knowledge.

Look:
Layout: