From 96973a7c33665b8999ae50ade33869767460b065 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 12 Feb 2014 16:27:59 +0100 Subject: [PATCH] AOF write error: retry with a frequency of 1 hz. --- src/redis.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/redis.c b/src/redis.c index aea225fe..1c877ffc 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1120,12 +1120,17 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) { } - /* AOF: we may have postponed buffer flush, or were not able to - * write our buffer because of write(2) error. Try again here. */ - if (server.aof_flush_postponed_start || - server.aof_last_write_status == REDIS_ERR) - { - flushAppendOnlyFile(0); + /* AOF postponed flush: Try at every cron cycle if the slow fsync + * completed. */ + if (server.aof_flush_postponed_start) flushAppendOnlyFile(0); + + /* AOF write errors: in this case we have a buffer to flush as well and + * clear the AOF error in case of success to make the DB writable again, + * however to try every second is enough in case of 'hz' is set to + * an higher frequency. */ + run_with_period(1000) { + if (server.aof_last_write_status == REDIS_ERR) + flushAppendOnlyFile(0); } /* Close clients that need to be closed asynchronous */ -- GitLab