]> git.saurik.com Git - redis.git/blobdiff - src/redis.c
ZMALLOC related stuff removed from config.h. They are now defined in zmalloc.h
[redis.git] / src / redis.c
index 263172259f5e9befb61acfaf4ec33fa0ba1338bd..8fbed746d478499b1b6b646f306f75eafb3db94d 100644 (file)
@@ -692,14 +692,16 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
          }
 
          /* Trigger an AOF rewrite if needed */
          }
 
          /* 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 base = server.auto_aofrewrite_base_size ?
                             server.auto_aofrewrite_base_size : 1;
              server.appendonly_current_size > server.auto_aofrewrite_min_size)
          {
             int base = server.auto_aofrewrite_base_size ?
                             server.auto_aofrewrite_base_size : 1;
-            int growth = (server.appendonly_current_size*100/base);
+            long long growth = (server.appendonly_current_size*100/base) - 100;
             if (growth >= server.auto_aofrewrite_perc) {
             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();
             }
          }
                 rewriteAppendOnlyFileBackground();
             }
          }
@@ -899,6 +901,7 @@ void initServerConfig() {
     server.replstate = REDIS_REPL_NONE;
     server.repl_syncio_timeout = REDIS_REPL_SYNCIO_TIMEOUT;
     server.repl_serve_stale_data = 1;
     server.replstate = REDIS_REPL_NONE;
     server.repl_syncio_timeout = REDIS_REPL_SYNCIO_TIMEOUT;
     server.repl_serve_stale_data = 1;
+    server.repl_down_since = -1;
 
     /* Double constants initialization */
     R_Zero = 0.0;
 
     /* Double constants initialization */
     R_Zero = 0.0;
@@ -1393,6 +1396,16 @@ sds genRedisInfoString(char *section) {
             server.lastsave,
             server.bgrewritechildpid != -1);
 
             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;
         if (server.loading) {
             double perc;
             time_t eta, elapsed;
@@ -1510,6 +1523,12 @@ sds genRedisInfoString(char *section) {
                     (int)(time(NULL)-server.repl_transfer_lastio)
                 );
             }
                     (int)(time(NULL)-server.repl_transfer_lastio)
                 );
             }
+
+            if (server.replstate != REDIS_REPL_CONNECTED) {
+                info = sdscatprintf(info,
+                    "master_link_down_since_seconds:%ld\r\n",
+                    (long)time(NULL)-server.repl_down_since);
+            }
         }
         info = sdscatprintf(info,
             "connected_slaves:%d\r\n",
         }
         info = sdscatprintf(info,
             "connected_slaves:%d\r\n",