Validate Redis persistence with AOF rewrite, fork headroom and an isolated restart
Redis writes succeed and the process runs normally, yet data is missing after a restart. Troubleshooting cannot stop at “AOF is enabled.” When a database and cache share a host, background persistence also introduces fork operations, copy-on-write overhead, and additional disk writes. Before going live, validate file creation, background job status, resource headroom, and data reloading separately rather than checking configuration switches alone.
This walkthrough uses Debian 13 with Redis 7 or later command-line tools already installed to create an isolated instance with no TCP listener. All writes go to a temporary directory. It neither connects to an existing production instance nor changes system service configuration.
1. Separate recovery goals from resource limits
RDB is a point-in-time snapshot of the data. AOF records write operations, and rewriting compacts the file set produced by that history. Enabling both does not automatically provide two verified recovery paths. When both are enabled, Redis normally loads AOF first at startup, so reading data back after a restart does not also prove that RDB recovery works.
Runner’s AMD dedicated servers use the AMD EPYC 7543P with 32 cores and 64 threads, with two DDR4-3200 ECC memory options: 128GB and 256GB. More capacity does not eliminate fork risk: the parent and child processes initially share memory pages, and changes made during the background job trigger copy-on-write. Peak usage depends on the write rate and how long the job runs.
maxmemoryis neither a hard memory limit for the entire Redis process nor a complete budget for background persistence. Do not allocate all physical memory to key-value data.
The two 1TB NVMe drives are each directly attached, with no hardware RAID. Even when both RDB and AOF are present locally, they are not an off-site backup and cannot protect against a host-wide storage failure.
2. Create a test instance that uses only a local socket
Run these commands as an unprivileged user, first checking redis-server --version and redis-cli --version. Keep the following variables in the same Bash session. The temporary directory must have enough free space, and you must not reuse a production data directory.
umask 077
lab=$(mktemp -d /tmp/redis-check.XXXXXX)
sock="$lab/redis.sock"
cat > "$lab/redis.conf" <<EOF
port 0
unixsocket $sock
unixsocketperm 700
daemonize yes
pidfile $lab/redis.pid
logfile $lab/redis.log
dir $lab
dbfilename dump.rdb
save ""
appendonly yes
appendfsync everysec
EOF
redis-server "$lab/redis.conf"
redis-cli -s "$sock" PING
redis-cli -s "$sock" SET audit:key baseline
redis-cli -s "$sock" GET audit:key
port 0 explicitly disables TCP listening. Every client command includes -s to avoid accidentally connecting to another instance. Expect PONG, OK, and baseline, respectively. If startup fails, inspect the log in the test directory first rather than masking the error with repeated startup attempts.
Next, check the effective settings instead of trusting only the configuration file you just wrote:
redis-cli -s "$sock" CONFIG GET dir
redis-cli -s "$sock" CONFIG GET appendonly
redis-cli -s "$sock" CONFIG GET appendfsync
redis-cli -s "$sock" INFO persistence
This example disables automatic RDB snapshot rules; snapshots will be triggered manually later. This is not a recommended retention policy for production.
3. Validate the snapshot and AOF rewrite in sequence
Create the snapshot first and wait for it to finish before rewriting AOF. A response saying that a background job has started means only that the request was accepted, not that the file is complete or the data has been synced.
redis-cli -s "$sock" BGSAVE
redis-cli -s "$sock" INFO persistence
Check the status repeatedly until rdb_bgsave_in_progress is 0, then verify that rdb_last_bgsave_status is ok and that a nonempty dump.rdb exists in the directory. If the operation fails, preserve the logs and check directory permissions, free space, and fork errors rather than immediately triggering it again.
Once it has finished, run:
redis-cli -s "$sock" BGREWRITEAOF
redis-cli -s "$sock" INFO persistence
find "$lab" -maxdepth 2 -type f -printf '%P %s bytes\n'
Wait until both aof_rewrite_in_progress and aof_rewrite_scheduled are 0, and confirm that aof_last_bgrewrite_status and aof_last_write_status are ok. If the job finishes very quickly, it is normal not to observe it in progress. Also check the completion records in the log.
Redis 7 and later commonly use multipart AOF: the manifest, base file, and incremental files together form the set needed for loading. The base file may use RDB encoding. A different file extension does not by itself indicate a configuration error, and copying just one file is not a valid backup.
4. Observe fork headroom under write load
A small sample validates only the operational sequence; it cannot establish production capacity. Load representative, sanitized data into a separate test environment, then reproduce the application’s write rate. Do not inject test keys directly into a production instance.
Capture the following before, during, and after background jobs:
redis-cli -s "$sock" INFO memory
redis-cli -s "$sock" INFO persistence
redis-cli -s "$sock" INFO stats
free -h
df -h "$lab"
Focus on used_memory, used_memory_rss, and latest_fork_usec, along with rdb_last_cow_size and aof_last_cow_size where the installed version provides them. If a field is missing, check its availability for that version; absence does not mean zero consumption.
Track job duration and write pressure on the same timeline
The longer a background job runs, the more opportunities the application has to modify shared pages. Validation records must capture dataset size, request rate, rewrite duration, available host memory, and application latency together. Recording RSS only after completion can miss an intermediate peak.
Also watch for a sustained increase in aof_delayed_fsync and correlate it with disk and application latency. This is a cumulative counter: compare its values before and after the test rather than declaring a current fault simply because it is nonzero. If problems appear, first reduce the write load or dataset size. Do not go straight to changing the host’s memory policy to “make the error disappear.”
5. Read data back after restart and document the findings
Confirm that background jobs have finished and their status is healthy, then perform an orderly shutdown and restart. These commands affect only the test instance; they do not restart production services:
redis-cli -s "$sock" SET audit:key after-rewrite
redis-cli -s "$sock" SHUTDOWN
redis-server "$lab/redis.conf"
redis-cli -s "$sock" PING
redis-cli -s "$sock" GET audit:key
redis-cli -s "$sock" INFO persistence
Expect to read back after-rewrite, and check the log to confirm which persistence source was actually loaded. If the read-back result is wrong, first preserve the entire directory, configuration, and logs. Do not run repair tools first: a repair may discard a damaged tail and alter the original evidence.
This test validates AOF rewriting and an orderly restart. With appendfsync everysec, there is still a window in which writes have not yet been synced, and a normal shutdown may also flush buffered data to disk. The result therefore does not establish that no data will be lost during a power failure. Test independent RDB recovery separately, using a copied snapshot and an isolated instance with AOF disabled.
The final record should include, at minimum, software versions, effective configuration, background job results, peak resource usage, and the value read back. Once no further inspection is needed, shut down the test instance and then delete the temporary directory created for this run. Before cleanup, verify that the variable still points to the path you created. Production readiness should be based on this reproducible evidence, not on a persistence switch.
Frequently asked questions
Does reading the original value after a clean restart prove power-loss durability?
No. It validates orderly shutdown and loading. With appendfsync everysec, writes may still be awaiting synchronization, so a successful read is not proof of power-loss durability.
Can old AOF fragments be deleted manually after a rewrite?
No. The manifest and associated files form a set managed by Redis. Do not delete fragments or overwrite the manifest; use a consistent backup procedure suitable for the installed version.
Runner EPYC 7543P Dedicated Server
From $450/month