You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AOF rewrite should call fdatasync per second to avoid block the main thread's write(2) #1019
On my 64G memory & 100MB/s HD test machine, when 10G AOF file is rewrited, the main thread's write(2) would be blocked from 7 second to 14 second , whole redis would be blocked.
"Asynchronous AOF fsync is taking too long (disk is busy?). Writing the AOF buffer without waiting for fsync to complete, this may slow down Redis." time and time again.
I change the system parameter to let the system flush to disk more often, avoid to flush too much data one time
sysctl vm.dirty_bytes=33554432(32M)
i think it is good to modify the AOF rewrite code, let it call fdatasync directly.
Thanks for your report, do you mean to call fdatasync in the child process that writes the AOF so that it avoids to accumulate too big buffers to flush on disk? We did something like that in replication during RDB transfer with good results actually so this probably makes sense for AOF as well.
Very interesting, thanks! I'll provide a branch with explicit fdatasync() call to see if the results are comparable to what you get modifying kernel parameters. Thanks for your help, it is appreciated.
Dear @springside, I just implemented what discussed here in the issue-1090 branch, please could you verify that the good effects now that we moved the idea inside Redis instead of modifying the kernel parameters are still here? :-)
The branch is a fork of unstable, but you'll be able to easily cherry pick the two commits implementing this into 2.6 if you need to, or I can make a 2.6 branch with the two commits for you if you want.
Feature made configurable and committed, so now we are set for a release... but I've another pending thing in Redis Sentinel that I need to address before committing.
@yoav-steinberg hi guy.
I have a question. when do you update "r->processed_bytes"?
I might think because of it, only it will call fsync, if (len > r->io.file.fsync_interval)
so you should add bytes_written to r->processed_bytes before returing rioWrite
@yoav-steinberg Hi, I might think I found another bug in your code.(but, it's trivial)
if bytes_written becomes larger than io.file.fsync_interval and if len remains,
after that, fsync will be called until loop is finished.
staticsize_trioFileWrite(rio*r, constvoid*buf, size_tlen) {
size_tbytes_written=0;
while (len) {
size_tbytes_to_write= (r->io.file.fsync_interval&&r->io.file.fsync_interval<len) ? r->io.file.fsync_interval : len;
if (fwrite((char*)buf+bytes_written,bytes_to_write,1,r->io.file.fp) !=1)
return0;
bytes_written+=bytes_to_write;
len-=bytes_to_write;
//There is a possibility to call fsync many times(not intented)//if bytes_written is larger than io.file.fsync_interval and if there are more data in current loopif (r->io.file.fsync_interval&&r->processed_bytes/r->io.file.fsync_interval< (r->processed_bytes+bytes_written)/r->io.file.fsync_interval)
fsync(fileno(r->io.file.fp));
}
return1;
}
Activity
antirez commentedon Mar 21, 2013
Thanks for your report, do you mean to call fdatasync in the child process that writes the AOF so that it avoids to accumulate too big buffers to flush on disk? We did something like that in replication during RDB transfer with good results actually so this probably makes sense for AOF as well.
antirez commentedon Mar 21, 2013
That's cool, however did you checked if the time to produce the AOF file changed in a measurable way? Thanks.
antirez commentedon Mar 21, 2013
Very interesting, thanks! I'll provide a branch with explicit fdatasync() call to see if the results are comparable to what you get modifying kernel parameters. Thanks for your help, it is appreciated.
AOF: sync data on disk every 32MB when rewriting.
antirez commentedon Apr 3, 2013
Dear @springside, I just implemented what discussed here in the issue-1090 branch, please could you verify that the good effects now that we moved the idea inside Redis instead of modifying the kernel parameters are still here? :-)
The branch is a fork of
unstable, but you'll be able to easily cherry pick the two commits implementing this into 2.6 if you need to, or I can make a 2.6 branch with the two commits for you if you want.Thank you in advance!
antirez commentedon Apr 3, 2013
Sorry I was wrong... cherry-pick is not possible so I'm creating a 2.6-issue-1090 branch right now.
AOF: sync data on disk every 32MB when rewriting.
antirez commentedon Apr 3, 2013
done :-)
antirez commentedon Apr 4, 2013
No rush! 7 April is perfect :-) Have a great vacation!
antirez commentedon Apr 24, 2013
Right now :-)
AOF: sync data on disk every 32MB when rewriting.
AOF: sync data on disk every 32MB when rewriting.
AOF: sync data on disk every 32MB when rewriting.
antirez commentedon Apr 24, 2013
Merged everywhere, now adding support to enable/disable it in redis.conf. By default this will be enabled. Thank you for your help!
antirez commentedon Apr 24, 2013
Feature made configurable and committed, so now we are set for a release... but I've another pending thing in Redis Sentinel that I need to address before committing.
yoav-steinberg commentedon May 2, 2013
Looking at the fix it seems like when writing more than 32MB (for example a 100MB key) we'll only get a single fsync. Am I missing something?
I've actually dealt with this in the past and came up with this patch: https://github.com/GarantiaData/redis/commit/4fe3d6bd40decabf1ddd3bdb5b69b87521e6233d
charsyam commentedon May 2, 2013
@yoav-steinberg hi guy.
I have a question. when do you update "r->processed_bytes"?
I might think because of it, only it will call fsync, if (len > r->io.file.fsync_interval)
so you should add bytes_written to r->processed_bytes before returing rioWrite
yoav-steinberg commentedon May 2, 2013
@charsyam, processed_bytes is updated in the rio layer (not specific to files). This is another change in the GarantiaData fork. You can find it here: https://github.com/GarantiaData/redis/commit/3aab06bcc7460b46c96fbb8d3b704ab1227c6be4
charsyam commentedon May 2, 2013
@yoav-steinberg Hi, I might think I found another bug in your code.(but, it's trivial)
if bytes_written becomes larger than io.file.fsync_interval and if len remains,
after that, fsync will be called until loop is finished.
yoav-steinberg commentedon May 2, 2013
@charsyam, keen eye and sorry for keeping posting these links :) anyway I fixed that bug shortly after, see: https://github.com/GarantiaData/redis/commit/785cf9297733e32110daed8ca8b16169ea4288b5
AOF: sync data on disk every 32MB when rewriting.
Update RedisBloom to v8.2.15 (#15528)