diff options
author | antirez <antirez@gmail.com> | 2012-08-24 19:28:44 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2012-08-28 12:47:33 +0200 |
commit | 784b93087c622999e225735c0c76d50241941022 (patch) | |
tree | f09a46b252c83b1c17cb0566e63be11317ea2cdd /src/config.h | |
parent | 1caa627e4e53c479f1ee1f1f80b1b980d55eef7f (diff) | |
download | redis-784b93087c622999e225735c0c76d50241941022.tar.gz |
Incrementally flush RDB on disk while loading it from a master.
This fixes issue #539.
Basically if there is enough free memory the OS may buffer the RDB file
that the slave transfers on disk from the master. The file may
actually be flused on disk at once by the operating system when it gets
closed by Redis, causing the close system call to block for a long time.
This patch is a modified version of one provided by yoav-steinberg of
@garantiadata (the original version was posted in the issue #539
comments), and tries to flush the OS buffers incrementally (every 8 MB
of loaded data).
Diffstat (limited to 'src/config.h')
-rw-r--r-- | src/config.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/config.h b/src/config.h index 28ef37d6e..617682fcf 100644 --- a/src/config.h +++ b/src/config.h @@ -52,6 +52,14 @@ #define aof_fsync fsync #endif +/* Define rdb_fsync_range to sync_file_range() on Linux, otherwise we use + * the plain fsync() call. */ +#ifdef __linux__ +#define rdb_fsync_range(fd,off,size) sync_file_range(fd,off,size,SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE) +#else +#define rdb_fsync_range(fd,off,size) fsync(fd) +#endif + /* Byte ordering detection */ #include <sys/types.h> /* This will likely define BYTE_ORDER */ |