]> git.saurik.com Git - redis.git/blobdiff - src/redis.c
Use a safe iterator while saving the DB, since the getExpire() function will access...
[redis.git] / src / redis.c
index 9243d55418dc52b263ab476addfee6557fab0c64..e7351b6ef5381001b8b78dc221fad40a85a12fc0 100644 (file)
@@ -692,13 +692,16 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
          }
 
          /* Trigger an AOF rewrite if needed */
-         if (server.auto_aofrewrite_perc &&
+         if (server.bgsavechildpid == -1 &&
+             server.bgrewritechildpid == -1 &&
+             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;
+            long long growth = (server.appendonly_current_size*100/base) - 100;
             if (growth >= server.auto_aofrewrite_perc) {
-                redisLog(REDIS_NOTICE,"Starting automatic rewriting of AOF on %d growth",growth);
+                redisLog(REDIS_NOTICE,"Starting automatic rewriting of AOF on %lld%% growth",growth);
                 rewriteAppendOnlyFileBackground();
             }
          }
@@ -1392,6 +1395,16 @@ sds genRedisInfoString(char *section) {
             server.lastsave,
             server.bgrewritechildpid != -1);
 
+        if (server.appendonly) {
+            info = sdscatprintf(info,
+                "aof_current_size:%lld\r\n"
+                "aof_base_size:%lld\r\n"
+                "aof_pending_rewrite:%d\r\n",
+                (long long) server.appendonly_current_size,
+                (long long) server.auto_aofrewrite_base_size,
+                server.aofrewrite_scheduled);
+        }
+
         if (server.loading) {
             double perc;
             time_t eta, elapsed;