Day 5: Corrupt the Storage File Manually and Handle Read Failures Gracefully
In Day 4, we successfully bypassed the volatile JVM heap to persist raw key-value pairs directly to disk using FileOutputStream, measuring the raw physical latency of our disk writes. However, simply getting bytes onto a platter or flash cells is only half the battle. In production, storage media is hostile.
Today, we transition from simple persistence to data integrity validation. We will implement record-level checksumming using CRC32 to detect silent data corruption, simulate a storage failure by manually corrupting our database file, and write the error-handling paths necessary to defend our storage engine against corrupted state. This capability is the direct foundation for Day 6, where we will assemble our resilient, disk-backed store into a unified command-line interface.
Real-World Context: When Hardware Lies
We often treat the operating system and underlying storage controllers as infallible black boxes. They are not.
Keep going with the full lesson
The rest of this lesson — plus its implementation guide, runnable scripts and source code — is included with the course or an All Access plan. Create a free account to start the free lessons in every course.
Already a member? Sign in