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.
- One connection runs a checkpoint that completes, leaving the log ready to be reset.
- Shortly afterwards, a second checkpoint starts.
- While it is starting up, another connection commits a transaction. That commit resets the log and writes new pages at its beginning.
- The second checkpoint does not notice the reset. It leaves a field in the WAL-index header saying part of the log has already been checkpointed, when it has not.
- More transactions are committed, until the log holds more pages than it did at step 1.
- A third checkpoint trusts the wrong field and skips all or part of the transaction from step 3.
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
- It does not show that SQLite databases are widely at risk. SQLite writes that "the occurrence rate of this problem in the wild appears to be less than or equal to the expected occurrence rate of SSD malfunctions and/or cosmic-ray hits."
- Nobody has counted other victims. That estimate rests on "available telemetry" which the page does not publish, and neither source names another affected user.
- Tailscale's direct proof is one reported alert. After upgrading, it added a warning for a write overlapping a log reset. It reports the warning firing two months later, calls the bug the "likely culprit", and has since gone four months without a database incident.
- Tailscale's losses are specific to Tailscale. It says these databases hold configuration metadata, never private encryption keys or network traffic, that in the earliest incidents a handful of newly added devices or configuration changes did not persist, and that most of its servers were never affected.
- The age is an estimate. Tailscale reports the developers' figure as at least 16 years. SQLite's version range spans about 15 and a half years.
- Reproduction came late. On 24 August 2026 SQLite noted that Phil Eaton had devised a reproducer that needs no special testing code.
Tailscale draws its own lesson about configuration: "running boring technology in a non-standard way is a risk."
Sources
- How we tracked down a 16-year-old SQLite bug
- Write-Ahead Logging, section 11: The WAL-Reset Bug
- SQLite Release 3.51.3 (13 March 2026)
- Check-in 7168988acb: the fix for the checkpointer and writer race
- How SQLite Is Tested
Related stories
- ISRO IRoC-U 2026: ASCEND Challenge for Autonomous UAV Navigation
- ISRO opens IRoC-U 2026 student challenge for GPS-free micro-UAVs
- Alibaba's Qwen releases open Qwen4-35B-A3B with 3B active
- MiniMax releases M4, a 2.74T-parameter model; weights to follow
- Subquadratic says its SubQ Savant AI takes up to 4 million tokens
- HilbNets framework covers graph, sheaf and gauge networks
More from Debug Duck
- xAI launches Grok Bot, an agent it says has its own computer
- Anthropic says Claude watermark may mean processed, not written
- Cloudflare open-sources Cloudflare OS, its internal AI workspace
- Many correct AI answers on hard science tests skip the reasoning
- Maths RL lifts one-try scores but narrows an 8B model's reach