summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-12-23 14:52:57 +0100
committerantirez <antirez@gmail.com>2014-12-23 14:52:57 +0100
commit22a0fe8de65124839d567f0d2f57f1dceced7e73 (patch)
tree8d2f7067aa0d98c3dd2e902cd9cd76ab163d6f07
parent585884da452764cbfac6252a8b227a1539c1c6e2 (diff)
downloadredis-22a0fe8de65124839d567f0d2f57f1dceced7e73.tar.gz
INFO loading stats: three fixes.
1. Server unxtime may remain not updated while loading AOF, so ETA is not updated correctly. 2. Number of processed byte was not initialized. 3. Possible division by zero condition (likely cause of issue #1932).
-rw-r--r--src/rdb.c3
-rw-r--r--src/redis.c6
2 files changed, 5 insertions, 4 deletions
diff --git a/src/rdb.c b/src/rdb.c
index db9e814d5..251399992 100644
--- a/src/rdb.c
+++ b/src/rdb.c
@@ -1087,8 +1087,9 @@ void startLoading(FILE *fp) {
/* Load the DB */
server.loading = 1;
server.loading_start_time = time(NULL);
+ server.loading_loaded_bytes = 0;
if (fstat(fileno(fp), &sb) == -1) {
- server.loading_total_bytes = 1; /* just to avoid division by zero */
+ server.loading_total_bytes = 0;
} else {
server.loading_total_bytes = sb.st_size;
}
diff --git a/src/redis.c b/src/redis.c
index 7db1d72ee..3a9ab219e 100644
--- a/src/redis.c
+++ b/src/redis.c
@@ -2633,14 +2633,14 @@ sds genRedisInfoString(char *section) {
server.loading_loaded_bytes;
perc = ((double)server.loading_loaded_bytes /
- server.loading_total_bytes) * 100;
+ (server.loading_total_bytes+1)) * 100;
- elapsed = server.unixtime-server.loading_start_time;
+ elapsed = time(NULL)-server.loading_start_time;
if (elapsed == 0) {
eta = 1; /* A fake 1 second figure if we don't have
enough info */
} else {
- eta = (elapsed*remaining_bytes)/server.loading_loaded_bytes;
+ eta = (elapsed*remaining_bytes)/(server.loading_loaded_bytes+1);
}
info = sdscatprintf(info,