Skip to content
This repository
Browse code

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
  • Loading branch information...
commit 78ebe4c88f5ca2e7bfc0d1a0b0481940daac83b4 1 parent d9eaa43
Salvatore Sanfilippo authored

Showing 1 changed file with 11 additions and 6 deletions. Show diff stats Hide diff stats

  1. +11 6 redis.c
17 redis.c
@@ -2834,7 +2834,6 @@ static void freeHashObject(robj *o) {
2834 2834 }
2835 2835
2836 2836 static void incrRefCount(robj *o) {
2837   - redisAssert(!server.vm_enabled || o->storage == REDIS_VM_MEMORY);
2838 2837 o->refcount++;
2839 2838 }
2840 2839
@@ -8703,7 +8702,10 @@ static void freeIOJob(iojob *j) {
8703 8702 j->type == REDIS_IOJOB_DO_SWAP ||
8704 8703 j->type == REDIS_IOJOB_LOAD) && j->val != NULL)
8705 8704 decrRefCount(j->val);
8706   - decrRefCount(j->key);
  8705 + /* We don't decrRefCount the j->key field as we did't incremented
  8706 + * the count creating IO Jobs. This is because the key field here is
  8707 + * just used as an indentifier and if a key is removed the Job should
  8708 + * never be touched again. */
8707 8709 zfree(j);
8708 8710 }
8709 8711
@@ -8876,7 +8878,7 @@ static void vmCancelThreadedIOJob(robj *o) {
8876 8878 iojob *job = ln->value;
8877 8879
8878 8880 if (job->canceled) continue; /* Skip this, already canceled. */
8879   - if (compareStringObjects(job->key,o) == 0) {
  8881 + if (job->key == o) {
8880 8882 redisLog(REDIS_DEBUG,"*** CANCELED %p (%s) (type %d) (LIST ID %d)\n",
8881 8883 (void*)job, (char*)o->ptr, job->type, i);
8882 8884 /* 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 9068 j = zmalloc(sizeof(*j));
9067 9069 j->type = REDIS_IOJOB_PREPARE_SWAP;
9068 9070 j->db = db;
9069   - j->key = dupStringObject(key);
  9071 + j->key = key;
9070 9072 j->val = val;
9071 9073 incrRefCount(val);
9072 9074 j->canceled = 0;
@@ -9134,7 +9136,7 @@ static int waitForSwappedKey(redisClient *c, robj *key) {
9134 9136 j = zmalloc(sizeof(*j));
9135 9137 j->type = REDIS_IOJOB_LOAD;
9136 9138 j->db = c->db;
9137   - j->key = dupStringObject(key);
  9139 + j->key = o;
9138 9140 j->key->vtype = o->vtype;
9139 9141 j->page = o->vm.page;
9140 9142 j->val = NULL;
@@ -9653,6 +9655,9 @@ static void debugCommand(redisClient *c) {
9653 9655 (void*)key, key->refcount, (unsigned long long) key->vm.page,
9654 9656 (unsigned long long) key->vm.usedpages));
9655 9657 }
  9658 + } else if (!strcasecmp(c->argv[1]->ptr,"swapin") && c->argc == 3) {
  9659 + lookupKeyRead(c->db,c->argv[2]);
  9660 + addReply(c,shared.ok);
9656 9661 } else if (!strcasecmp(c->argv[1]->ptr,"swapout") && c->argc == 3) {
9657 9662 dictEntry *de = dictFind(c->db->dict,c->argv[2]);
9658 9663 robj *key, *val;
@@ -9684,7 +9689,7 @@ static void debugCommand(redisClient *c) {
9684 9689 }
9685 9690 } else {
9686 9691 addReplySds(c,sdsnew(
9687   - "-ERR Syntax error, try DEBUG [SEGFAULT|OBJECT <key>|SWAPOUT <key>|RELOAD]\r\n"));
  9692 + "-ERR Syntax error, try DEBUG [SEGFAULT|OBJECT <key>|SWAPIN <key<|SWAPOUT <key>|RELOAD]\r\n"));
9688 9693 }
9689 9694 }
9690 9695

0 comments on commit 78ebe4c

Please sign in to comment.
Something went wrong with that request. Please try again.