Commit 78ebe4c8 authored by antirez's avatar antirez
Browse files

use directly the real key object in VM I/O jobs to match by pointer, and to...

use directly the real key object in VM I/O jobs to match by pointer, and to handle different keys with the same name living in different DBs, but being at the same moment in the IO job queues
parent d9eaa43a
...@@ -2834,7 +2834,6 @@ static void freeHashObject(robj *o) { ...@@ -2834,7 +2834,6 @@ static void freeHashObject(robj *o) {
} }
static void incrRefCount(robj *o) { static void incrRefCount(robj *o) {
redisAssert(!server.vm_enabled || o->storage == REDIS_VM_MEMORY);
o->refcount++; o->refcount++;
} }
...@@ -8703,7 +8702,10 @@ static void freeIOJob(iojob *j) { ...@@ -8703,7 +8702,10 @@ static void freeIOJob(iojob *j) {
j->type == REDIS_IOJOB_DO_SWAP || j->type == REDIS_IOJOB_DO_SWAP ||
j->type == REDIS_IOJOB_LOAD) && j->val != NULL) j->type == REDIS_IOJOB_LOAD) && j->val != NULL)
decrRefCount(j->val); decrRefCount(j->val);
decrRefCount(j->key); /* We don't decrRefCount the j->key field as we did't incremented
* the count creating IO Jobs. This is because the key field here is
* just used as an indentifier and if a key is removed the Job should
* never be touched again. */
zfree(j); zfree(j);
} }
...@@ -8876,7 +8878,7 @@ again: ...@@ -8876,7 +8878,7 @@ again:
iojob *job = ln->value; iojob *job = ln->value;
if (job->canceled) continue; /* Skip this, already canceled. */ if (job->canceled) continue; /* Skip this, already canceled. */
if (compareStringObjects(job->key,o) == 0) { if (job->key == o) {
redisLog(REDIS_DEBUG,"*** CANCELED %p (%s) (type %d) (LIST ID %d)\n", redisLog(REDIS_DEBUG,"*** CANCELED %p (%s) (type %d) (LIST ID %d)\n",
(void*)job, (char*)o->ptr, job->type, i); (void*)job, (char*)o->ptr, job->type, i);
/* Mark the pages as free since the swap didn't happened /* Mark the pages as free since the swap didn't happened
...@@ -9066,7 +9068,7 @@ static int vmSwapObjectThreaded(robj *key, robj *val, redisDb *db) { ...@@ -9066,7 +9068,7 @@ static int vmSwapObjectThreaded(robj *key, robj *val, redisDb *db) {
j = zmalloc(sizeof(*j)); j = zmalloc(sizeof(*j));
j->type = REDIS_IOJOB_PREPARE_SWAP; j->type = REDIS_IOJOB_PREPARE_SWAP;
j->db = db; j->db = db;
j->key = dupStringObject(key); j->key = key;
j->val = val; j->val = val;
incrRefCount(val); incrRefCount(val);
j->canceled = 0; j->canceled = 0;
...@@ -9134,7 +9136,7 @@ static int waitForSwappedKey(redisClient *c, robj *key) { ...@@ -9134,7 +9136,7 @@ static int waitForSwappedKey(redisClient *c, robj *key) {
j = zmalloc(sizeof(*j)); j = zmalloc(sizeof(*j));
j->type = REDIS_IOJOB_LOAD; j->type = REDIS_IOJOB_LOAD;
j->db = c->db; j->db = c->db;
j->key = dupStringObject(key); j->key = o;
j->key->vtype = o->vtype; j->key->vtype = o->vtype;
j->page = o->vm.page; j->page = o->vm.page;
j->val = NULL; j->val = NULL;
...@@ -9653,6 +9655,9 @@ static void debugCommand(redisClient *c) { ...@@ -9653,6 +9655,9 @@ static void debugCommand(redisClient *c) {
(void*)key, key->refcount, (unsigned long long) key->vm.page, (void*)key, key->refcount, (unsigned long long) key->vm.page,
(unsigned long long) key->vm.usedpages)); (unsigned long long) key->vm.usedpages));
} }
} else if (!strcasecmp(c->argv[1]->ptr,"swapin") && c->argc == 3) {
lookupKeyRead(c->db,c->argv[2]);
addReply(c,shared.ok);
} else if (!strcasecmp(c->argv[1]->ptr,"swapout") && c->argc == 3) { } else if (!strcasecmp(c->argv[1]->ptr,"swapout") && c->argc == 3) {
dictEntry *de = dictFind(c->db->dict,c->argv[2]); dictEntry *de = dictFind(c->db->dict,c->argv[2]);
robj *key, *val; robj *key, *val;
...@@ -9684,7 +9689,7 @@ static void debugCommand(redisClient *c) { ...@@ -9684,7 +9689,7 @@ static void debugCommand(redisClient *c) {
} }
} else { } else {
addReplySds(c,sdsnew( addReplySds(c,sdsnew(
"-ERR Syntax error, try DEBUG [SEGFAULT|OBJECT <key>|SWAPOUT <key>|RELOAD]\r\n")); "-ERR Syntax error, try DEBUG [SEGFAULT|OBJECT <key>|SWAPIN <key<|SWAPOUT <key>|RELOAD]\r\n"));
} }
} }
......
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