Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

New in INFO: aof_last_bgrewrite_status #586

Merged
merged 1 commit into from

2 participants

@saj

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 saj 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
@antirez antirez merged commit 04950a9 into antirez:unstable
@antirez
Owner

Thanks! merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 17, 2012
  1. @saj

    New in INFO: aof_last_bgrewrite_status

    saj authored
    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.)
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 3 deletions.
  1. +6 −0 src/aof.c
  2. +6 −3 src/redis.c
  3. +1 −0  src/redis.h
View
6 src/aof.c
@@ -1093,6 +1093,8 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) {
server.aof_buf = sdsempty();
}
+ server.aof_lastbgrewrite_status = REDIS_OK;
+
redisLog(REDIS_NOTICE, "Background AOF rewrite finished successfully");
/* Change state from WAIT_REWRITE to ON if needed */
if (server.aof_state == REDIS_AOF_WAIT_REWRITE)
@@ -1104,9 +1106,13 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) {
redisLog(REDIS_VERBOSE,
"Background AOF rewrite signal handler took %lldus", ustime()-now);
} else if (!bysignal && exitcode != 0) {
+ server.aof_lastbgrewrite_status = REDIS_ERR;
+
redisLog(REDIS_WARNING,
"Background AOF rewrite terminated with error");
} else {
+ server.aof_lastbgrewrite_status = REDIS_ERR;
+
redisLog(REDIS_WARNING,
"Background AOF rewrite terminated by signal %d", bysignal);
}
View
9 src/redis.c
@@ -1114,6 +1114,7 @@ void initServerConfig() {
server.aof_last_fsync = time(NULL);
server.aof_rewrite_time_last = -1;
server.aof_rewrite_time_start = -1;
+ server.aof_lastbgrewrite_status = REDIS_OK;
server.aof_delayed_fsync = 0;
server.aof_fd = -1;
server.aof_selected_db = -1; /* Make sure the first time will not match */
@@ -1957,12 +1958,13 @@ sds genRedisInfoString(char *section) {
"aof_rewrite_in_progress:%d\r\n"
"aof_rewrite_scheduled:%d\r\n"
"aof_last_rewrite_time_sec:%ld\r\n"
- "aof_current_rewrite_time_sec:%ld\r\n",
+ "aof_current_rewrite_time_sec:%ld\r\n"
+ "aof_last_bgrewrite_status:%s\r\n",
server.loading,
server.dirty,
server.rdb_child_pid != -1,
server.lastsave,
- server.lastbgsave_status == REDIS_OK ? "ok" : "err",
+ (server.lastbgsave_status == REDIS_OK) ? "ok" : "err",
server.rdb_save_time_last,
(server.rdb_child_pid == -1) ?
-1 : time(NULL)-server.rdb_save_time_start,
@@ -1971,7 +1973,8 @@ sds genRedisInfoString(char *section) {
server.aof_rewrite_scheduled,
server.aof_rewrite_time_last,
(server.aof_child_pid == -1) ?
- -1 : time(NULL)-server.aof_rewrite_time_start);
+ -1 : time(NULL)-server.aof_rewrite_time_start,
+ (server.aof_lastbgrewrite_status == REDIS_OK) ? "ok" : "err");
if (server.aof_state != REDIS_AOF_OFF) {
info = sdscatprintf(info,
View
1  src/redis.h
@@ -644,6 +644,7 @@ struct redisServer {
time_t aof_last_fsync; /* UNIX time of last fsync() */
time_t aof_rewrite_time_last; /* Time used by last AOF rewrite run. */
time_t aof_rewrite_time_start; /* Current AOF rewrite start time. */
+ int aof_lastbgrewrite_status; /* REDIS_OK or REDIS_ERR */
unsigned long aof_delayed_fsync; /* delayed AOF fsync() counter */
/* RDB persistence */
long long dirty; /* Changes to DB from the last save */
Something went wrong with that request. Please try again.