diff --git a/src/aof.c b/src/aof.c index dfd58853c32..ac6cf64143c 100644 --- a/src/aof.c +++ b/src/aof.c @@ -833,7 +833,7 @@ int openNewIncrAofForAppend(void) { * is already synced at this point so fsync doesn't matter. */ if (server.aof_fd != -1) { aof_background_fsync_and_close(server.aof_fd); - server.aof_last_fsync = server.unixtime; + server.aof_last_fsync = server.mstime; } server.aof_fd = newfd; @@ -954,7 +954,7 @@ void stopAppendOnly(void) { if (redis_fsync(server.aof_fd) == -1) { serverLog(LL_WARNING,"Fail to fsync the AOF file: %s",strerror(errno)); } else { - server.aof_last_fsync = server.unixtime; + server.aof_last_fsync = server.mstime; } close(server.aof_fd); @@ -998,7 +998,7 @@ int startAppendOnly(void) { return C_ERR; } } - server.aof_last_fsync = server.unixtime; + server.aof_last_fsync = server.mstime; /* If AOF fsync error in bio job, we just ignore it and log the event. */ int aof_bio_fsync_status; atomicGet(server.aof_bio_fsync_status, aof_bio_fsync_status); @@ -1074,7 +1074,7 @@ void flushAppendOnlyFile(int force) { * the data in page cache cannot be flushed in time. */ if (server.aof_fsync == AOF_FSYNC_EVERYSEC && server.aof_last_incr_fsync_offset != server.aof_last_incr_size && - server.unixtime > server.aof_last_fsync && + server.mstime - server.aof_last_fsync >= 1000 && !(sync_in_progress = aofFsyncInProgress())) { goto try_fsync; @@ -1260,15 +1260,15 @@ void flushAppendOnlyFile(int force) { latencyEndMonitor(latency); latencyAddSampleIfNeeded("aof-fsync-always",latency); server.aof_last_incr_fsync_offset = server.aof_last_incr_size; - server.aof_last_fsync = server.unixtime; + server.aof_last_fsync = server.mstime; atomicSet(server.fsynced_reploff_pending, server.master_repl_offset); } else if (server.aof_fsync == AOF_FSYNC_EVERYSEC && - server.unixtime > server.aof_last_fsync) { + server.mstime - server.aof_last_fsync >= 1000) { if (!sync_in_progress) { aof_background_fsync(server.aof_fd); server.aof_last_incr_fsync_offset = server.aof_last_incr_size; } - server.aof_last_fsync = server.unixtime; + server.aof_last_fsync = server.mstime; } } diff --git a/src/server.c b/src/server.c index e743eeb8c7a..a63276f7509 100644 --- a/src/server.c +++ b/src/server.c @@ -2053,7 +2053,7 @@ void initServerConfig(void) { server.aof_rewrite_base_size = 0; server.aof_rewrite_scheduled = 0; server.aof_flush_sleep = 0; - server.aof_last_fsync = time(NULL); + server.aof_last_fsync = time(NULL) * 1000; server.aof_cur_timestamp = 0; atomicSet(server.aof_bio_fsync_status,C_OK); server.aof_rewrite_time_last = -1; diff --git a/src/server.h b/src/server.h index edc93087426..b23c0ae2508 100644 --- a/src/server.h +++ b/src/server.h @@ -1779,7 +1779,7 @@ struct redisServer { int aof_fd; /* File descriptor of currently selected AOF file */ int aof_selected_db; /* Currently selected DB in AOF */ time_t aof_flush_postponed_start; /* UNIX time of postponed AOF flush */ - time_t aof_last_fsync; /* UNIX time of last fsync() */ + time_t aof_last_fsync; /* mstime of last fsync() */ time_t aof_rewrite_time_last; /* Time used by last AOF rewrite run. */ time_t aof_rewrite_time_start; /* Current AOF rewrite start time. */ time_t aof_cur_timestamp; /* Current record timestamp in AOF */