<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/nightmare-mode-simulating-disk-failures-caediivwb" -->

---
title: Nightmare mode: simulating disk failures | daily.dev
description: Antithesis built a 'nightmare mode' fault injector that simulates disk failures like power loss, torn writes, I/O errors, and latency races to catch storage...
canonical: https://daily.dev/posts/nightmare-mode-simulating-disk-failures-caediivwb
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Nightmare mode: simulating disk failures | daily.dev
og:description: Antithesis built a 'nightmare mode' fault injector that simulates disk failures like power loss, torn writes, I/O errors, and latency races to catch storage...
og:url: https://daily.dev/posts/nightmare-mode-simulating-disk-failures-caediivwb
og:image: https://api.daily.dev/og/posts/cAEDIivWB.png
og:image:alt: Nightmare mode: simulating disk failures
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Nightmare mode: simulating disk failures

**[Antithesis](https://daily.dev/sources/antithesis)** · 17 min read · 0 upvotes · 0 comments

## Summary

Antithesis built a 'nightmare mode' fault injector that simulates disk failures like power loss, torn writes, I/O errors, and latency races to catch storage bugs. It started by running a patched version of the open-source FUSE filesystem LazyFS, then built its own Rust-based FUSE filesystem called Amnesia, which models an fsync as an in-memory bookkeeping update instead of real I/O. The injector found a real bug in bbolt, etcd's storage engine, where an EIO on an fsync of a meta page caused bbolt to treat an uncommitted transaction as committed, leading to a panic on every open after the cached page was evicted. The tool also emulates the fsyncgate bug, where a failed fsync silently clears a page's dirty flag so the data is never retried.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://antithesis.com/blog/2026/nightmare-mode>

## Questions this post answers

### What causes the fsyncgate bug where PostgreSQL could silently lose data after a failed fsync?

When an fsync fails with EIO on Linux, the kernel still clears the dirty flag on the pages it tried to write before confirming success. Since the page is marked clean, neither the next fsync nor background writeback retries it, so the data is silently dropped unless the program rewrites and re-dirties the same pages. PostgreSQL developer Craig Ringer reported this, and PostgreSQL now crashes and recovers from its log instead of retrying a failed fsync.

_Teams hardening storage engines against fsync failures can track these postmortems and fixes on daily.dev._

### What is the bbolt bug in etcd that causes it to panic on every restart?

bbolt commits a transaction in two fsynced steps: writing data pages, then a meta page pointing at them. If the data pages sync but the meta page's fsync fails with EIO, etcd exits, but on restart bbolt reads the stale meta page from the kernel page cache and wrongly treats the transaction as committed, rebuilding its free page list incorrectly. Once that cached page is evicted, the on-disk meta page points at overwritten pages and bbolt panics on every subsequent open, with the write-ahead log unable to help because the store never finishes opening.

_Engineers debugging etcd storage corruption can follow bbolt fault reports like this on daily.dev._

### How does LazyFS emulate power loss for filesystem testing without actually cutting power to a machine?

LazyFS is a FUSE-based userspace filesystem that holds written data in its own internal cache, mimicking the kernel's page cache, and only writes to persistent storage when a program calls fsync, with no background writeback. Clearing that internal cache at the same moment the application process is killed produces an effect indistinguishable from a real power failure, since any unsynced data in the cache is simply dropped.

_Developers designing crash-safety tests for storage systems can find tools like this through daily.dev._

## Similar posts on daily.dev

- [Testing Distributed Systems Under Chaos](https://daily.dev/posts/testing-distributed-systems-under-chaos-zmikzoshx) · Tigris · 3 upvotes · 1 comments
- [Animations for System Builders](https://daily.dev/posts/animations-for-system-builders-isu7bvaxr) · Hacker News · 0 upvotes · 0 comments
- [Animations for System Builders: Metastability and Lost Writes](https://daily.dev/posts/animations-for-system-builders-metastability-and-lost-writes-bgx0frg1n) · Marc Brooker · 0 upvotes · 0 comments

---

Tags: [#rust](https://daily.dev/tags/rust), [#distributed-systems](https://daily.dev/tags/distributed-systems), [#filesystems](https://daily.dev/tags/filesystems)

[View this post on daily.dev](https://daily.dev/posts/nightmare-mode-simulating-disk-failures-caediivwb)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Nightmare mode: simulating disk failures","url":"https://daily.dev/posts/nightmare-mode-simulating-disk-failures-caediivwb","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/nightmare-mode-simulating-disk-failures-caediivwb"},"datePublished":"2026-11-24T15:40:41.360Z","dateModified":"2026-11-24T15:41:13.092Z","description":"Antithesis built a 'nightmare mode' fault injector that simulates disk failures like power loss, torn writes, I/O errors, and latency races to catch storage...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/5834905d6d0712a0fc4984f4b6e7d995?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/5834905d6d0712a0fc4984f4b6e7d995?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Antithesis","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Antithesis","logo":"https://media.daily.dev/image/upload/s--17qPGZ9J--/f_auto,q_auto/v1788684980/logos/antithesis?_a=BAMAMicg0","url":"https://daily.dev/sources/antithesis"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/nightmare-mode-simulating-disk-failures-caediivwb","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"rust,distributed-systems,filesystems","timeRequired":"PT17M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Antithesis","item":"https://daily.dev/sources/antithesis"},{"@type":"ListItem","position":3,"name":"Nightmare mode: simulating disk failures"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/nightmare-mode-simulating-disk-failures-caediivwb#faq","mainEntity":[{"@type":"Question","name":"What causes the fsyncgate bug where PostgreSQL could silently lose data after a failed fsync?","acceptedAnswer":{"@type":"Answer","text":"When an fsync fails with EIO on Linux, the kernel still clears the dirty flag on the pages it tried to write before confirming success. Since the page is marked clean, neither the next fsync nor background writeback retries it, so the data is silently dropped unless the program rewrites and re-dirties the same pages. PostgreSQL developer Craig Ringer reported this, and PostgreSQL now crashes and recovers from its log instead of retrying a failed fsync. Teams hardening storage engines against fsync failures can track these postmortems and fixes on daily.dev."}},{"@type":"Question","name":"What is the bbolt bug in etcd that causes it to panic on every restart?","acceptedAnswer":{"@type":"Answer","text":"bbolt commits a transaction in two fsynced steps: writing data pages, then a meta page pointing at them. If the data pages sync but the meta page's fsync fails with EIO, etcd exits, but on restart bbolt reads the stale meta page from the kernel page cache and wrongly treats the transaction as committed, rebuilding its free page list incorrectly. Once that cached page is evicted, the on-disk meta page points at overwritten pages and bbolt panics on every subsequent open, with the write-ahead log unable to help because the store never finishes opening. Engineers debugging etcd storage corruption can follow bbolt fault reports like this on daily.dev."}},{"@type":"Question","name":"How does LazyFS emulate power loss for filesystem testing without actually cutting power to a machine?","acceptedAnswer":{"@type":"Answer","text":"LazyFS is a FUSE-based userspace filesystem that holds written data in its own internal cache, mimicking the kernel's page cache, and only writes to persistent storage when a program calls fsync, with no background writeback. Clearing that internal cache at the same moment the application process is killed produces an effect indistinguishable from a real power failure, since any unsynced data in the cache is simply dropped. Developers designing crash-safety tests for storage systems can find tools like this through daily.dev."}}]}
```

