Skip to content
This repository

New in INFO: aof_last_bgrewrite_status #586

Merged
merged 1 commit into from over 1 year ago

2 participants

Saj Goonatilleke Salvatore Sanfilippo
Saj Goonatilleke
saj commented July 17, 2012

AOF rewriting is too important to go unmonitored. Redis can easily fill its filesystem with AOF data if failing rewrites go unnoticed by operators. This pull request introduces a new data point in INFO that behaves just like rdb_last_bgsave_status for AOF persistence.

Saj Goonatilleke New in INFO: aof_last_bgrewrite_status
Behaves like rdb_last_bgsave_status -- even down to reporting 'ok' when
no rewrite has been done yet.  (You might want to check that
aof_last_rewrite_time_sec is not -1.)
48553a2
Salvatore Sanfilippo antirez merged commit 04950a9 into from July 27, 2012
Salvatore Sanfilippo antirez closed this July 27, 2012
Salvatore Sanfilippo
Owner

Thanks! merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jul 18, 2012
Saj Goonatilleke New in INFO: aof_last_bgrewrite_status
Behaves like rdb_last_bgsave_status -- even down to reporting 'ok' when
no rewrite has been done yet.  (You might want to check that
aof_last_rewrite_time_sec is not -1.)
48553a2
This page is out of date. Refresh to see the latest.
6  src/aof.c
@@ -1093,6 +1093,8 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) {
1093 1093
             server.aof_buf = sdsempty();
1094 1094
         }
1095 1095
 
  1096
+        server.aof_lastbgrewrite_status = REDIS_OK;
  1097
+
1096 1098
         redisLog(REDIS_NOTICE, "Background AOF rewrite finished successfully");
1097 1099
         /* Change state from WAIT_REWRITE to ON if needed */
1098 1100
         if (server.aof_state == REDIS_AOF_WAIT_REWRITE)
@@ -1104,9 +1106,13 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) {
1104 1106
         redisLog(REDIS_VERBOSE,
1105 1107
             "Background AOF rewrite signal handler took %lldus", ustime()-now);
1106 1108
     } else if (!bysignal && exitcode != 0) {
  1109
+        server.aof_lastbgrewrite_status = REDIS_ERR;
  1110
+
1107 1111
         redisLog(REDIS_WARNING,
1108 1112
             "Background AOF rewrite terminated with error");
1109 1113
     } else {
  1114
+        server.aof_lastbgrewrite_status = REDIS_ERR;
  1115
+
1110 1116
         redisLog(REDIS_WARNING,
1111 1117
             "Background AOF rewrite terminated by signal %d", bysignal);
1112 1118
     }
9  src/redis.c
@@ -1114,6 +1114,7 @@ void initServerConfig() {
1114 1114
     server.aof_last_fsync = time(NULL);
1115 1115
     server.aof_rewrite_time_last = -1;
1116 1116
     server.aof_rewrite_time_start = -1;
  1117
+    server.aof_lastbgrewrite_status = REDIS_OK;
1117 1118
     server.aof_delayed_fsync = 0;
1118 1119
     server.aof_fd = -1;
1119 1120
     server.aof_selected_db = -1; /* Make sure the first time will not match */
@@ -1957,12 +1958,13 @@ sds genRedisInfoString(char *section) {
1957 1958
             "aof_rewrite_in_progress:%d\r\n"
1958 1959
             "aof_rewrite_scheduled:%d\r\n"
1959 1960
             "aof_last_rewrite_time_sec:%ld\r\n"
1960  
-            "aof_current_rewrite_time_sec:%ld\r\n",
  1961
+            "aof_current_rewrite_time_sec:%ld\r\n"
  1962
+            "aof_last_bgrewrite_status:%s\r\n",
1961 1963
             server.loading,
1962 1964
             server.dirty,
1963 1965
             server.rdb_child_pid != -1,
1964 1966
             server.lastsave,
1965  
-            server.lastbgsave_status == REDIS_OK ? "ok" : "err",
  1967
+            (server.lastbgsave_status == REDIS_OK) ? "ok" : "err",
1966 1968
             server.rdb_save_time_last,
1967 1969
             (server.rdb_child_pid == -1) ?
1968 1970
                 -1 : time(NULL)-server.rdb_save_time_start,
@@ -1971,7 +1973,8 @@ sds genRedisInfoString(char *section) {
1971 1973
             server.aof_rewrite_scheduled,
1972 1974
             server.aof_rewrite_time_last,
1973 1975
             (server.aof_child_pid == -1) ?
1974  
-                -1 : time(NULL)-server.aof_rewrite_time_start);
  1976
+                -1 : time(NULL)-server.aof_rewrite_time_start,
  1977
+            (server.aof_lastbgrewrite_status == REDIS_OK) ? "ok" : "err");
1975 1978
 
1976 1979
         if (server.aof_state != REDIS_AOF_OFF) {
1977 1980
             info = sdscatprintf(info,
1  src/redis.h
@@ -644,6 +644,7 @@ struct redisServer {
644 644
     time_t aof_last_fsync;            /* UNIX time of last fsync() */
645 645
     time_t aof_rewrite_time_last;   /* Time used by last AOF rewrite run. */
646 646
     time_t aof_rewrite_time_start;  /* Current AOF rewrite start time. */
  647
+    int aof_lastbgrewrite_status;   /* REDIS_OK or REDIS_ERR */
647 648
     unsigned long aof_delayed_fsync;  /* delayed AOF fsync() counter */
648 649
     /* RDB persistence */
649 650
     long long dirty;                /* Changes to DB from the last save */
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.