summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2010-09-08 13:26:16 +0200
committerantirez <antirez@gmail.com>2010-09-08 13:26:16 +0200
commit7f00cd226438d3cd91238974346cee624d8920e1 (patch)
treeb2ac5f925405fb7bf554e812df6cd0e166c2c202
parentefc5d4cc0dd285b45061d61d7a717777aa8bc7a0 (diff)
downloadredis-7f00cd226438d3cd91238974346cee624d8920e1.tar.gz
Fixed a race condition in VM happening when a key was deleted while there was a client waiting for this key to be resumed from swap to memory. The client would hang forever.
-rw-r--r--src/db.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/db.c b/src/db.c
index f380bf6ec..ca520c825 100644
--- a/src/db.c
+++ b/src/db.c
@@ -123,6 +123,11 @@ robj *dbRandomKey(redisDb *db) {
/* Delete a key, value, and associated expiration entry if any, from the DB */
int dbDelete(redisDb *db, robj *key) {
+ /* If VM is enabled make sure to awake waiting clients for this key:
+ * deleting the key will kill the I/O thread bringing the key from swap
+ * to memory, so the client will never be notified and unblocked if we
+ * don't do it now. */
+ handleClientsBlockedOnSwappedKey(db,key);
/* Deleting an entry from the expires dict will not free the sds of
* the key, because it is shared with the main dictionary. */
if (dictSize(db->expires) > 0) dictDelete(db->expires,key->ptr);