From e3d27a726162e9faefe2d6223caf3b459b7f94f7 Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 10 Jun 2011 14:25:27 +0200 Subject: [PATCH] Avoid division by zero issues in the automatically triggered AOF rewrite feature. --- src/redis.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/redis.c b/src/redis.c index 9243d554..26317225 100644 --- a/src/redis.c +++ b/src/redis.c @@ -695,8 +695,9 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) { if (server.auto_aofrewrite_perc && server.appendonly_current_size > server.auto_aofrewrite_min_size) { - int growth = (server.appendonly_current_size*100/ - server.auto_aofrewrite_base_size); + int base = server.auto_aofrewrite_base_size ? + server.auto_aofrewrite_base_size : 1; + int growth = (server.appendonly_current_size*100/base); if (growth >= server.auto_aofrewrite_perc) { redisLog(REDIS_NOTICE,"Starting automatic rewriting of AOF on %d growth",growth); rewriteAppendOnlyFileBackground(); -- 2.45.2