Skip to content
Browse files

Merge remote-tracking branch 'origin/unstable' into unstable

  • Loading branch information...
2 parents 3f194a9 + f3a6143 commit 7f5bdba4343cf32c8ae7d38a3f6d0d163677c14c @antirez committed Jul 28, 2012
Showing with 21 additions and 3 deletions.
  1. +13 −0 src/aof.c
  2. +6 −3 src/redis.c
  3. +1 −0 src/redis.h
  4. +1 −0 src/sentinel.c
View
13 src/aof.c
@@ -250,6 +250,13 @@ void flushAppendOnlyFile(int force) {
strerror(errno),
(long)nwritten,
(long)sdslen(server.aof_buf));
+
+ if (ftruncate(server.aof_fd, server.aof_current_size) == -1) {
+ redisLog(REDIS_WARNING, "Could not remove short write "
+ "from the append-only file. Redis may refuse "
+ "to load the AOF the next time it starts. "
+ "ftruncate: %s", strerror(errno));
+ }
}
exit(1);
}
@@ -1093,6 +1100,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 +1113,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
@@ -1121,6 +1121,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 */
@@ -1967,12 +1968,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,
@@ -1981,7 +1983,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
@@ -652,6 +652,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 */
View
1 src/sentinel.c
@@ -36,6 +36,7 @@
#include <ctype.h>
#include <arpa/inet.h>
#include <sys/socket.h>
+#include <sys/wait.h>
extern char **environ;

0 comments on commit 7f5bdba

Please sign in to comment.
Something went wrong with that request. Please try again.