Commit e8de5c7a authored by antirez's avatar antirez
Browse files

Fix for VM swapping out at DB loading time when key is shared

parent 61e4ff2f
...@@ -4131,10 +4131,18 @@ static int rdbLoad(char *filename) { ...@@ -4131,10 +4131,18 @@ static int rdbLoad(char *filename) {
if (de) { if (de) {
key = dictGetEntryKey(de); key = dictGetEntryKey(de);
val = dictGetEntryVal(de); val = dictGetEntryVal(de);
if (val->refcount != 1) continue;
/* Unshare the key if needed */
if (key->refcount != 1) {
robj *newkey = dupStringObject(key);
decrRefCount(key);
key = dictGetEntryKey(de) = newkey;
}
if (vmSwapObjectBlocking(key,val) == REDIS_OK) { if (vmSwapObjectBlocking(key,val) == REDIS_OK)
dictGetEntryVal(de) = NULL; dictGetEntryVal(de) = NULL;
}
} }
continue; continue;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment