From 172f14d48c26d35435a77cafbb49458a1a788887 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 22 Jan 2014 09:54:43 +0100 Subject: [PATCH] Use fflush() before fsync() in rio.c. Incremental flushing in rio.c is only used to avoid huge kernel buffers synched to slow disks creating big latency spikes, so this fix has no durability implications, however it is certainly more correct to make sure that the FILE buffers are flushed to the kernel before calling fsync on the file descriptor. Thanks to Li Shao Kai for reporting this issue in the Redis mailing list. --- src/rio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rio.c b/src/rio.c index 405e789e..44f9b7a0 100644 --- a/src/rio.c +++ b/src/rio.c @@ -86,6 +86,7 @@ static size_t rioFileWrite(rio *r, const void *buf, size_t len) { if (r->io.file.autosync && r->io.file.buffered >= r->io.file.autosync) { + fflush(r->io.file.fp); aof_fsync(fileno(r->io.file.fp)); r->io.file.buffered = 0; }