From 5d4675979de5d2f6709658f4e3e6344182d8f35e Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Wed, 17 Aug 2011 18:15:06 +0200 Subject: [PATCH] Fix AOF race that may duplicate commands --- src/aof.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/aof.c b/src/aof.c index b0852c47f..5c051e05b 100644 --- a/src/aof.c +++ b/src/aof.c @@ -657,6 +657,11 @@ void backgroundRewriteDoneHandler(int statloc) { if (server.appendfsync != APPENDFSYNC_NO) aof_fsync(fd); server.appendseldb = -1; /* Make sure it will issue SELECT */ redisLog(REDIS_NOTICE,"The new append only file was selected for future appends."); + + /* Clear regular AOF buffer since its contents was just written to + * the new AOF from the background rewrite buffer. */ + sdsfree(server.aofbuf); + server.aofbuf = sdsempty(); } else { /* If append only is disabled we just generate a dump in this * format. Why not? */