Repository navigation
Use named volumes for data persistence and add AOF repair - #261
Merged
Merged
Conversation
On Docker Desktop the ./data bind mount goes through the host file-sharing layer, whose fsync doesn't make the AOF durable: an unclean stop left the incremental AOF with a garbage tail, and Redis restart-looped on "Bad file format reading the append only file". RedisInsight's ./data/redisinsight was nested inside that mount, so after ./data was deleted Docker had to create both host directories at once and failed with "error while creating mount source path ...: file exists". Redis and RedisInsight now use their own named volumes, and with REDIS_AOF_AUTOFIX=yes (the compose default) the broker checks the AOF before starting and truncates it at the first bad command, keeping the damaged files in /data/appendonlydir.damaged. It stays off by default in the image, since the check reads the whole AOF on every start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S2yuRDKRKriR3NMgBXzQ7s
The ./pgdata bind mount had the same problem as the broker's ./data on Docker Desktop: the host file-sharing layer doesn't make Postgres's WAL durable, so an unclean stop could corrupt the database. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S2yuRDKRKriR3NMgBXzQ7s
Codecov Report✅ All modified and coverable lines are covered by tests. Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves data durability and reliability by switching from bind mounts to named volumes for persistent data storage, and adds automatic repair of corrupted Redis append-only files (AOF) at startup.
Key Changes
Switch to named volumes: Replaced bind mounts (
./pgdata,./data,./data/redisinsight) with named Docker volumes (db_data,broker_data,broker_insight_data) for Postgres, Redis, and RedisInsight. This ensures data durability on Docker Desktop where bind mounts don't guarantee fsync durability through the host file-sharing layer.Add Redis AOF auto-repair: Implemented automatic detection and repair of corrupted Redis append-only files in
shepherd_broker/entrypoint.sh. WhenREDIS_AOF_AUTOFIX=yes(enabled by default), the broker checks the AOF manifest at startup and truncates damaged files at the first bad command, preventing restart loops. Damaged files are backed up toappendonlydir.damagedfor inspection.Add
REDIS_AOF_AUTOFIXenvironment variable: New optional configuration incompose.yml(defaults toyes) to control AOF auto-repair behavior.Update documentation: Added comprehensive section to README explaining the data volume changes, AOF repair behavior, and how to reset volumes.
Implementation Details
redis-check-aofto validate the manifest andredis-check-aof --fixto repair it, with proper error handling and user guidance if repair fails.REDIS_AOF_AUTOFIX=noif preferred.volumes:section at the end ofcompose.yml.