Skip to content

Field Notes

Redis MISCONF: Permanent Fix for Failed RDB Snapshots

How to recover from Redis MISCONF safely, understand stop-writes-on-bgsave-error, and fix the persistence failure instead of hiding it.

EmailLinkedIn
Redis persistence recoveryBGSAVE failureWrite protectionDiagnosisPermanent repairVerification
Redis persistence recovery
Check Expected result Failure meaning
Disk and inodes Usable headroom Snapshot cannot be written
Persistence state Last BGSAVE is ok Durability protection is active
Redis directory Writable by Redis user Path, mount or policy mismatch
On this page

Environment covered: Redis 6/7 on Linux or containers with RDB persistence enabled

Redis can reject new writes after an RDB snapshot fails while continuing to serve existing values. In a cache that is inconvenient; in a job queue it can stop new work from being recorded even though the application and workers still appear available.

Treat MISCONF as a persistence failure first. Before restarting anything, establish the last recoverable state, the failed operation and the storage or memory boundary that prevented it.

The queue and filesystem fault below are reconstructed examples, informed by Redis recovery work. A separate persistence qualification supports the restore-test discussion; it does not establish that this illustrative incident occurred.

Establish which persistence operation failed

Consider a small application that uses Redis for both cached values and background-job state. Existing values can still be read, but adding work fails after a background snapshot error. That asymmetry changes the investigation: this is not initially a DNS failure, an authentication failure or a completely unavailable process.

The first question is what Redis was asked to persist and when it last succeeded. Run these against the intended instance using its normal approved authentication mechanism; do not put passwords in a shared command history.

redis-cli INFO persistence
redis-cli LASTSAVE
redis-cli CONFIG GET dir
redis-cli CONFIG GET dbfilename
redis-cli CONFIG GET save
redis-cli CONFIG GET appendonly

rdb_last_bgsave_status:err points to the last snapshot operation, while rdb_bgsave_in_progress tells you whether a child is still working. Neither field identifies the filesystem failure by itself. An AOF write error is another durability path and needs its own log evidence; changing an RDB setting does not repair it.

For a queue, the distinction matters beyond the error message. A process can accept an HTTP request before successfully recording the corresponding job. Application acceptance, queue admission and durable Redis state are different boundaries. A useful incident trace follows the same job across them.

Check the write path from inside the runtime

In this scenario, the Redis log reports a write failure in the snapshot directory. The host filesystem has free space, and an operator can create a file there as root. Both observations are true. Neither proves that the Redis process can write the directory it sees.

The missing question is the runtime boundary. A container may see a different mount; a deployment may change its UID; a volume may become read-only. A systemd service can also have a restricted view of otherwise writable storage.

df -h /var/lib/redis
df -i /var/lib/redis
findmnt -T /var/lib/redis
namei -l /var/lib/redis

Here /var/lib/redis is an illustrative path, not a universal default. Use the dir returned by the running server. For a container, inspect that path and the mapped volume from the container’s namespace. Then test access as the actual service UID, with a disposable filename that cannot overwrite a snapshot.

In our reconstruction, a volume-ownership change explains the failed write. The corrective action is to restore the intended ownership and mount contract, rather than making the directory writable to everyone. Recheck access after the next container replacement; a one-off host permission change that the deployment immediately reverses is not a durable repair.

When the same symptom comes from memory

If the log instead says the snapshot child could not be created, a permission change is irrelevant. BGSAVE uses a child process, and copy-on-write can add memory pressure while the parent continues accepting changes. Inspect process memory, cgroup limits and kernel OOM evidence together. A dataset that fits at idle can still exceed the runtime budget during a busy save.

redis-cli INFO memory
sysctl vm.overcommit_memory
journalctl -k --since '30 minutes ago'

Those are observations, not a recommendation to change kernel settings blindly. Keep Redis’s kernel safety checks enabled. A failed check in an emulated environment also does not establish that a native production kernel is safe; qualify the real runtime separately.

Keep write protection during the repair

Disabling stop-writes-on-bgsave-error does not make a snapshot succeed. It changes whether Redis continues accepting writes after an RDB failure. For disposable cache entries that may be an acceptable, explicitly owned trade-off. For queue state, sessions or primary data, the loss window may be unacceptable.

That decision needs the data’s role, the last recoverable save and the consequences of a restart. Do not silently turn it into a standard recovery step. The example repair keeps protection enabled and fixes the underlying write path.

There is another trap: enabling AOF during the incident is not an instant escape from bad storage. AOF also needs a healthy filesystem, and rewrite work has capacity implications. Choose persistence policy from recovery requirements, then test it; do not redesign durability while guessing at the current fault.

Verify a completed save and an isolated restore

Once the write path is healthy, start a save in a controlled window and observe completion rather than treating the initial acknowledgement as success.

redis-cli CONFIG GET stop-writes-on-bgsave-error
redis-cli BGSAVE
redis-cli INFO persistence
redis-cli LASTSAVE

BGSAVE returning “started” is not the result. Wait for the child to finish, confirm the latest status is ok, and check that the successful-save time advances. Inspect the resulting artifact at the configured location without deleting the previous known-good copy.

The retained qualification evidence adds a stronger check: background saves were followed by reload tests on isolated copies while writes and copy-on-write behavior were observed. That proves more than a healthy dashboard at the end of a quiet save. It still does not establish an unlimited capacity claim.

A recovery drill should verify representative keys, expirations and application behavior using the matching Redis version in an isolated environment. If both RDB and AOF are configured, confirm which artifact the restart actually uses. Otherwise a successful restart can accidentally validate a different persistence path from the one just repaired.

Return the queue to service

Validate an application write, the next scheduled save and the alert path for another failure. For a queue, also check that a newly admitted job can be processed and that retries have not duplicated work accepted around the failure. Leave enough disk and memory headroom for a busy save, not only the idle dataset.

Record the repaired mount or ownership contract in the deployment source. The restore test establishes what can be recovered; the deployment change keeps the next replacement from recreating the fault.

Sources and further investigation

References support the protocol and product behavior discussed here; they are not evidence that the illustrative scenario occurred.

Continue the investigation

Need a second set of eyes?

Working through a similar production issue?

Discuss the technical context