antirez/redis — Issue #161: a bug about aofrewrite_scheduled
Author: hoterran
Created: 2011-10-26 08:05:54+00:00
State: open

i has post in google group.

when bgsave is doing, if user trigger bgrewriteaof, then
aofrewrite_scheduled = 1
but there not other set aofrewrite_scheduled back to 0, possible
bug???
==============all code about aofrewrite_scheduled ====
./src/redis.h: int aofrewrite_scheduled; /* Rewrite once
BGSAVE terminates. */
./src/redis.c: server.aofrewrite_scheduled)
./src/redis.c: server.aofrewrite_scheduled = 0; #just
init
./src/redis.c: server.aofrewrite_scheduled);
./src/aof.c: server.aofrewrite_scheduled = 1;
where server.aofrewrite_scheduled = 0;
==============use gdb test log =============
[15108] 26 Oct 15:46:52 * Background append only file rewriting
started by pid 15259
[15259] 26 Oct 15:46:52 * SYNC append only file rewrite performed
[15108] 26 Oct 15:46:52 * Background AOF rewrite terminated with
success
[15108] 26 Oct 15:46:52 * Parent diff successfully flushed to the
rewritten AOF (0 bytes)
[15108] 26 Oct 15:46:52 * Background AOF rewrite successful
[15108] 26 Oct 15:46:52 - Background AOF rewrite signal handler took
277us
[15108] 26 Oct 15:46:52 * Background append only file rewriting
started by pid 15260
[15260] 26 Oct 15:46:52 * SYNC append only file rewrite performed
[15108] 26 Oct 15:46:53 * Background AOF rewrite terminated with
success
[15108] 26 Oct 15:46:53 * Parent diff successfully flushed to the
rewritten AOF (0 bytes)
[15108] 26 Oct 15:46:53 * Background AOF rewrite successful
[15108] 26 Oct 15:46:53 - Background AOF rewrite signal handler took
207us
[15108] 26 Oct 15:46:53 * Background append only file rewriting
started by pid 15261
[15261] 26 Oct 15:46:53 * SYNC append only file rewrite performed
[15108] 26 Oct 15:46:53 * Background AOF rewrite terminated with
success
[15108] 26 Oct 15:46:53 * Parent diff successfully flushed to the
rewritten AOF (0 bytes)
[15108] 26 Oct 15:46:53 * Background AOF rewrite successful
[15108] 26 Oct 15:46:53 - Background AOF rewrite signal handler took
239us
[15108] 26 Oct 15:46:53 * Background append only file rewriting
started by pid 15262
[15262] 26 Oct 15:46:53 * SYNC append only file rewrite performed
[15108] 26 Oct 15:46:53 * Background AOF rewrite terminated with
success
[15108] 26 Oct 15:46:53 * Parent diff successfully flushed to the
rewritten AOF (0 bytes)
[15108] 26 Oct 15:46:53 * Background AOF rewrite successful
[15108] 26 Oct 15:46:53 - Background AOF rewrite signal handler took
212us
............................. repeat bgrewriteaof ............................

================my fix ==========================
598 if (server.bgsavechildpid == -1 && server.bgrewritechildpid
== -1 &&
599 server.aofrewrite_scheduled)
600 {
601 rewriteAppendOnlyFileBackground();
server.aofrewrite_scheduled = 0 // my add
602 }

Code i tested, is ok