1

Here is the code snippet in the end of flushAppendOnlyFile function in aof.c, which writes aof buffer on disk.

/* Perform the fsync if needed. */
if (server.aof_fsync == AOF_FSYNC_ALWAYS) {
    server.aof_last_fsync = server.unixtime;
} else if ((server.aof_fsync == AOF_FSYNC_EVERYSEC &&
            server.unixtime > server.aof_last_fsync)) {
    // Why create fsync job only while sync_in_progress is false?
    if (!sync_in_progress) aof_background_fsync(server.aof_fd);
    server.aof_last_fsync = server.unixtime;
}

Redis bio implements a background job list for fsync. Function aof_background_fsync appends a new fsync job to list.

Why dose redis create fsync job on this file only while sync_in_progress is false? If sync_in_progress is true, there is several fsync jobs waiting to be executed. Why does redis refuse to append this fsync job in such condition?

(Here is whole flushAppendOnlyFile function)

lorneli
  • 252
  • 3
  • 11

0 Answers0