Created
March 18, 2014 12:19
-
-
Save Dynom/9618999 to your computer and use it in GitHub Desktop.
Redis unexpected behaviour when enabling AOF after the fact.
This file contains 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
Steps to reproduce: | |
# Make sure that in your redis.conf: | |
appendonly no | |
# Also make sure that, in your redis.conf: | |
dbfilename FOO-dump.rdb | |
save "900 1" | |
save "300 10" | |
save "60 10000" | |
# Then do the following: | |
sudo -u redis redis-server /etc/redis/redis.conf --port 9999 | |
redis 127.0.0.1:9999> keys * | |
(empty list or set) | |
redis 127.0.0.1:9999> set foo bar | |
OK | |
redis 127.0.0.1:9999> set foo2 bar2 | |
OK | |
redis 127.0.0.1:9999> set foo3 bar3 | |
OK | |
redis 127.0.0.1:9999> keys * | |
1) "foo2" | |
2) "foo3" | |
3) "foo" | |
redis 127.0.0.1:9999> save | |
OK | |
redis 127.0.0.1:9999> config get dbfilename | |
1) "dbfilename" | |
2) "FOO-dump.rdb" | |
redis 127.0.0.1:9999> shutdown | |
redis 127.0.0.1:9999> quit | |
# Proof that the rdb was written: | |
ls -halF /var/lib/redis/FOO-dump.rdb | |
-rw-r--r-- 1 redis redis 51 Mar 18 12:58 /var/lib/redis/FOO-dump.rdb | |
# Proof that the appendonly.aof file doesn't exist yet: | |
ls -halF /var/lib/redis/appendonly.aof | |
ls: cannot access /var/lib/redis/appendonly.aof: No such file or directory | |
# Enable AOF, edit redis.conf and change appendonly (don't specify the dbfilename, it defaults to appendonly.aof) | |
appendonly yes | |
# Re-start the daemon | |
sudo -u redis redis-server /etc/redis/redis.conf --port 9999 | |
# Test for keys | |
redis-cli -p 9999 keys \* | |
(empty list or set) | |
# Trying to recover, use NOSAVE else the RDB is rewritten with 0 keys. The default is to save. | |
redis-cli -p 9999 shutdown NOSAVE | |
# Disable appendonly in redis.conf | |
appendonly no | |
# Re-starting the daemon | |
sudo -u redis redis-server /etc/redis/redis.conf --port 9999 | |
# Testing for keys | |
redis-cli -p 9999 keys \* | |
1) "foo3" | |
2) "foo" | |
3) "foo2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment