Databases

Redis returns MISCONF and stops accepting writes after BGSAVE failure

Environment

Environment

Standalone Redis 6.2 on Linux with AOF disabled and RDB periodic snapshots, persistent storage on network-mounted volume, moderate write traffic from web app.

Symptoms

Symptoms

Errors returned to clients: MISCONF Redis is configured to stop accepting writes, background saving failed; recently a BGSAVE started and terminated with error in server log.

Observations

Observations

Server log contains 'Background saving terminated with error', and dmesg shows no OOM killer events. Disk where dump.rdb would be written is near capacity or mounted with permission/IO problems. Redis memory usage below maxmemory but BGSAVE fork failed.

Already attempted

Already attempted

Tried CONFIG SET stop-writes-on-bgsave-error no and then attempted writes; server accepted writes afterwards but this is a temporary and risky setting. Restarting Redis was considered but deferred due to production traffic.

Diagnostic steps

Diagnostic steps

  1. Inspect Redis logs (redis-server log) around the BGSAVE timestamp for the exact error message and check dmesg and syslog for kernel OOM or I/O errors.
  • What the result means: If logs show 'fork: Cannot allocate memory', it's a fork/oom problem. If logs indicate write errors or 'No space left on device', it's a storage capacity or permission issue.
  1. Check free disk space and filesystem health on the directory where dump.rdb is written (df -h and dmesg for I/O errors); if using NFS, check mount options and server-side availability.
  • What the result means: Low free space or I/O errors explain failed RDB write. If NFS shows stale mounts or permissions problems, persistence will fail until storage is fixed.
  1. Run Redis CONFIG GET stop-writes-on-bgsave-error and inspect vm.overcommit_memory and available swap/ram; consider simulating a background save with BGSAVE manual and watch logs.
  • What the result means: If stop-writes-on-bgsave-error is enabled and BGSAVE still fails, avoid disabling it until root cause fixed. If overcommit is strict and fork fails, adjust OS settings or ensure enough memory/swap for copy-on-write.
  1. If you must allow writes temporarily, perform CONFIG SET stop-writes-on-bgsave-error no, then trigger a manual BGSAVE and monitor; plan to revert the config after resolving the storage/fork issue.
  • What the result means: If writes are accepted but BGSAVE still fails, data will not be persisted; risk of data loss on crash. If manual BGSAVE succeeds, persistence restored and safe to leave writes enabled, but underlying cause should still be investigated.
Confirmed fixes

Confirmed fixes

No fix has been independently verified for this scenario. Treat the causes below as diagnostic hypotheses.

Question

Question

How to safely diagnose root cause of BGSAVE failure and restore write capability without data loss, and what precautions before toggling stop-writes-on-bgsave-error?

COMMUNITY RESPONSES

Verified community troubleshooting

1 reply
0
novanetwork Answer
user
Posted 2w ago • 0 confirmations

First, read the Redis server log entry for the BGSAVE failure and correlate with df -h and dmesg around the timestamp. A 'No space left on device' or write errors point to storage; 'fork: Cannot allocate memory' indicates fork/overcommit issues. Fix the underlying cause (free space, fix NFS mount, adjust overcommit or add swap), then trigger a manual BGSAVE. Only after a successful BGSAVE is it safe to rely on writes; temporary CONFIG SET stop-writes-on-bgsave-error no is reversible but accept the risk and revert after persistence is restored.

Showing 1 of 1 community responses
AI DIAGNOSTICS

Incident analysis

Updated 2w ago• Trouble ID

Most likely causes

Insufficient disk space or filesystem errors on persistence target causing RDB write failures 80%
Permission or mount issues on the dump directory (NFS/remote storage behaving poorly) 65%
Fork failed due to low available virtual memory or OS overcommit restrictions 60%

Summary

MISCONF after BGSAVE failure indicates Redis disabled writes to avoid potential data loss if persistence is unreliable. Common BGSAVE failures: insufficient disk space, permission denied, IO errors, or fork failures (OOM). Turning off stop-writes-on-bgsave-error allows writes but risks accepting data that won't persist; safer path is to fix underlying I/O and let a successful BGSAVE occur, or perform a controlled restart with persistence validated.

Suggested Fixes

Diagnostic step 1
Inspect Redis logs (redis-server log) around the BGSAVE timestamp for the exact error message and check dmesg and syslog for kernel OOM or I/O errors. Result meaning: If logs show 'fork: Cannot allocate memory', it's a fork/oom problem. If logs indicate write errors or 'No space left on device', it's a storage capacity or permission issue.
Diagnostic step 2
Check free disk space and filesystem health on the directory where dump.rdb is written (df -h and dmesg for I/O errors); if using NFS, check mount options and server-side availability. Result meaning: Low free space or I/O errors explain failed RDB write. If NFS shows stale mounts or permissions problems, persistence will fail until storage is fixed.
Diagnostic step 3
Run Redis CONFIG GET stop-writes-on-bgsave-error and inspect vm.overcommit_memory and available swap/ram; consider simulating a background save with BGSAVE manual and watch logs. Result meaning: If stop-writes-on-bgsave-error is enabled and BGSAVE still fails, avoid disabling it until root cause fixed. If overcommit is strict and fork fails, adjust OS settings or ensure enough memory/swap for copy-on-write.

Continue troubleshooting

Matched from the title, description and tags