Redis AOF (Non-Default) Durability Test

5 Dec 2015

Let's make some changes to our Redis conf file so that we use the append-only file and set fsync to the most conservative setting possible.

$ gvim /usr/local/redis-3.0.5/conf/6379.conf 
# turn on AOL
appendonly no  ==>  appendonly yes
# force an fsync after each write; this is slow, but durable
appendfsync everysec  ==>  appendfsync always

Now, go re-run our tests.

In user terminal:

$ ./insert-ints
...
inserted 1010
inserted 1011
inserted 1012
inserted 1013
inserted 1014
Did not insert 1015

In root window:

# ./kill-redis.sh
# # systemctl start redis-6379.service

In user window:

$ ../get-last-written.sh max integer
"1015"
min integer
"1"
number of integers
(integer) 1015

Nice. I could test this more to see why 1015 was written even though my program didn't think it was, but more likely than not it's the same situation that is also possible with PostgreSQL: It's possible to kill the server between the time the insert is committed and the acknowledgement is sent to the client.

Also, anecdotally (and this should come as no surprise) the writes seemed to go a lot slower as they scrolled by in my terminal.