Permalink
Browse files

fix infinity loop by randomkey if the slave only has expired key.

  • Loading branch information...
1 parent fdf50e1 commit 2f17af6df5aeb0860c1b807867f159256912fc4b Minsu Choi committed Dec 31, 2013
Showing with 4 additions and 0 deletions.
  1. +4 −0 src/db.c
View
@@ -150,6 +150,10 @@ robj *dbRandomKey(redisDb *db) {
if (dictFind(db->expires,key)) {
if (expireIfNeeded(db,keyobj)) {
decrRefCount(keyobj);
+ /* Escaping from infinite loop by RANDOMKEY if slave has only expired key. */
+ if (server.masterhost != NULL && dictSize(db->dict) == dictSize(db->expires)) {
+ return NULL;
+ }
continue; /* search for another key. This expired. */
}
}

0 comments on commit 2f17af6

Please sign in to comment.