Redis failed to save its RDB snapshot because the target directory was full, preventing the redis-server process from writing the snapshot data.
Cause 1: Disk Full
Diagnosis: Check the available disk space on the Redis data directory.
df -h /var/lib/redis
If the output shows 100% usage for the partition containing /var/lib/redis, the disk is full.
Fix:
Free up space on the disk. This could involve deleting old log files, unused data, or resizing the disk. For example, to remove old RDB files (assuming they are named dump-*.rdb and are older than 7 days):
find /var/lib/redis/dump-*.rdb -type f -mtime +7 -delete
This command finds RDB files older than 7 days and deletes them, making space for new snapshots.
Why it works: Redis needs free space in the configured dir to write the RDB file. By removing older, unneeded snapshot files, you provide the necessary room.
Cause 2: Permissions Issue
Diagnosis:
Verify that the redis user (or the user running redis-server) has write permissions to the dir specified in redis.conf.
ls -ld /var/lib/redis
The output should show the redis user or group as the owner and have w permissions for the owner. For example: drwxr-xr-x 2 redis redis 4096 Nov 15 10:00 /var/lib/redis.
Fix:
If permissions are incorrect, change them to grant write access to the redis user.
sudo chown redis:redis /var/lib/redis
sudo chmod 755 /var/lib/redis
This ensures the redis process can create and write files within its data directory.
Why it works: The redis-server process runs as a specific user. Without write permissions on the snapshot directory, it cannot create the RDB file, even if there is disk space.
Cause 3: Incorrect dir Configuration
Diagnosis:
Check the dir directive in your redis.conf file.
grep '^dir' /etc/redis/redis.conf
Ensure the path specified exists and is accessible. For example, it might be set to dir /var/lib/redis.
Fix:
If the dir path is incorrect or doesn’t exist, correct it in redis.conf and restart Redis.
# Example: If dir was mistakenly set to /var/redis_data
# Change in redis.conf to:
# dir /var/lib/redis
# Then restart Redis
sudo systemctl restart redis-server
This ensures Redis is looking for and attempting to write snapshots to the correct location.
Why it works: Redis strictly adheres to the dir directive for storing its persistence files. An incorrect path means it tries to write to a non-existent or inaccessible location.
Cause 4: Read-Only Filesystem
Diagnosis:
Check if the filesystem where /var/lib/redis resides is mounted as read-only.
mount | grep '/var/lib/redis'
Look for ro in the mount options. For example, /dev/sda1 on /var/lib/redis type ext4 (ro,relatime,data=ordered).
Fix:
Remount the filesystem as read-write. This usually requires editing /etc/fstab to remove the ro option for that partition and then rebooting or remounting.
# Example: Edit /etc/fstab to change 'ro' to 'rw' for the relevant line.
# Then, remount (or reboot):
sudo mount -o remount,rw /var/lib/redis
A read-only filesystem prevents any write operations, including RDB snapshots.
Why it works: If the entire partition is mounted read-only (often due to filesystem errors detected on boot), no process can write to it. Remounting it as read-write allows Redis to perform its write operations.
Cause 5: Inode Exhaustion
Diagnosis: Check if the filesystem has run out of inodes, even if there is free disk space.
df -i /var/lib/redis
If the IUse% column is at or near 100%, the filesystem has no more inodes available for new files.
Fix: Delete unnecessary small files from the filesystem to free up inodes. If this is a persistent problem, consider reformatting the partition with more inodes or migrating to a larger filesystem.
# Example: Delete old, small log files that might be consuming inodes
find /var/lib/redis -type f -name "*.log" -mtime +30 -delete
Each file, regardless of size, consumes an inode. Running out of inodes means no new files can be created, even with ample byte space.
Why it works: Redis needs to create a new RDB file. If there are no available inodes on the partition, the operating system cannot allocate one for the new file, leading to the write failure.
Cause 6: appendonly Mode Conflict (less common for RDB specific errors)
Diagnosis:
While this error is specifically about RDB, a misconfiguration involving both appendonly and RDB can sometimes manifest strangely. Check your redis.conf for appendonly yes.
Fix:
Ensure that if appendonly is enabled, RDB snapshots are also configured appropriately (e.g., save directives are still active). If you intend to only use AOF, you might disable RDB saving explicitly by commenting out save lines, but the error indicates RDB tried to save. If you want both, ensure there’s enough disk space for both persistence mechanisms.
Why it works: Although typically separate, if Redis is under extreme load or experiencing internal issues, a conflict in persistence operations, coupled with disk space or permission issues, could lead to an RDB save failure. This is a less direct cause for the RDB snapshot failure itself but worth checking if other causes are ruled out.
Once these issues are resolved, the next error you might encounter is a MASTERDOWN error if Redis is configured as a replica and cannot reach its master.