A rare SQLite bug corrupted Tailscale's databases 19 times

A bug in the software you pick to avoid bugs

Tailscale's service links a customer's devices into a mesh network. The servers that coordinate those networks keep their records in SQLite, a database the company says it chose because it is "well-known, reliable, and widely used". SQLite's developers publish the reason for that reputation: as of version 3.42.0 the project had about 590 times as much test code as library code.

Yet starting in August 2025 Tailscale's databases kept turning up corrupted. The company counts 19 separate instances over six months. The cause was inside SQLite: a timing fault that SQLite's developers say has likely been there since 2010. It is so rare that, even after fixing it, they could not make it happen without altering SQLite's source code to force it.

Three ideas you need first

A SQLite database file is made of pages, small blocks of information. In the mode Tailscale uses, changed pages are not written straight into the database file. They are added to the end of a second file, the write-ahead log, or WAL. A change counts as committed once a commit record is appended there.

The log cannot grow forever, so its contents are periodically copied back into the main database file. That copying is called a checkpoint. Once a checkpoint has moved everything across and no reader still needs the log, the next writer rewinds it and starts again from the beginning. That rewind is the reset the bug is named after. SQLite keeps a small shared record, the WAL-index, which includes a note of how far checkpointing has got.

The third idea is a race condition: a fault that appears only when two activities running at the same time happen to interleave in one particular order.

How does the SQLite bug corrupt a database?

SQLite's documentation lays out the sequence.

The skipped pages never reach the database file. Tailscale's post describes the result: that data is permanently lost, and the file becomes corrupt because other pages that refer to the missing ones, such as an index, were written.

How it was caught

Tailscale's account, written by Alex Chan, says the corruption followed no pattern: no single server, customer, feature, time of day or load level. Unable to reproduce the fault, the team bought a professional support contract from the SQLite developers and instrumented its live systems.

Two clues pointed at checkpoints. Tailscale had begun logging every statement that changed a database, to replay onto a good backup. In two incidents the replay failed, because data committed by one transaction was invisible to later ones. And during incidents SQLite reported copying more pages out of the log than the log contained.

The SQLite developers then wrote a tracing layer, the tmstmpvfs shim, which wraps the part of SQLite that talks to the file system and logs what it does. Tailscale funded and deployed it. After the next incident its logs let the SQLite developers find the fault, which they confirmed accounted for everything Tailscale had seen. SQLite credits one of its developers, Dan, with finding and fixing it on 3 March 2026.

Why Tailscale? Most applications let SQLite decide when to checkpoint. Tailscale takes manual control, for fast and consistent backups, and by its own description checkpoints "very aggressively".

Is my SQLite database at risk?

SQLite states the conditions narrowly. The database must be in WAL mode. Two or more connections must be open on the same file, in separate threads or processes. And two of them must try to write or checkpoint at the same instant.

The bug is "likely present" in every version from 3.7.0, released on 21 July 2010 and the first to offer a write-ahead log, through 3.51.2. It is fixed in 3.51.3, released on 13 March 2026, and in later versions. The fix was also backported as 3.44.6 and 3.50.7. According to Tailscale, it adds a check to the checkpoint code that detects when the log has been reset by another thread.

A first release of the fix, 3.52.0 on 6 March, was withdrawn after an unrelated change caused false corruption warnings in 13 Tailscale databases.

SQLite advises upgrading, and adds: "However, this is not an emergency."

What this does not show

Tailscale draws its own lesson about configuration: "running boring technology in a non-standard way is a risk."

Sources

Related stories

More from Debug Duck

All stories from Debug Duck