summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhaozhao.zz <zhaozhao.zz@alibaba-inc.com>2017-11-18 01:21:39 +0800
committerantirez <antirez@gmail.com>2017-11-21 09:50:18 +0100
commitfd5f229ff0b6888b8e62488b4bd646f731d507ad (patch)
treed5982a4db5453d7e831a38ebfd77b46a8ddd1e06
parentbab437bef33075583841f292b1cb43194b53c50f (diff)
downloadredis-fd5f229ff0b6888b8e62488b4bd646f731d507ad.tar.gz
rehash: handle one db until finished
-rw-r--r--src/server.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/server.c b/src/server.c
index 6565b0b70..072ceb38f 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1056,12 +1056,15 @@ void databasesCron(void) {
/* Rehash */
if (server.activerehashing) {
for (j = 0; j < dbs_per_call; j++) {
- int work_done = incrementallyRehash(rehash_db % server.dbnum);
- rehash_db++;
+ int work_done = incrementallyRehash(rehash_db);
if (work_done) {
/* If the function did some work, stop here, we'll do
* more at the next cron loop. */
break;
+ } else {
+ /* If this db didn't need rehash, we'll try the next one. */
+ rehash_db++;
+ rehash_db %= server.dbnum;
}
}
}