From 0aed6a952a0acf5a02ec4b588031ec3dc231a68c Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 10 Mar 2011 16:39:19 +0100 Subject: [PATCH] fixed diskstore race condition --- src/dscache.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/dscache.c b/src/dscache.c index 2dbc1134..cbe9bb01 100644 --- a/src/dscache.c +++ b/src/dscache.c @@ -890,8 +890,16 @@ int waitForSwappedKey(redisClient *c, robj *key) { listAddNodeTail(l,c); /* Are we already loading the key from disk? If not create a job */ - if (de == NULL) - cacheScheduleIO(c->db,key,REDIS_IO_LOAD); + if (de == NULL) { + int flags = cacheScheduleIOGetFlags(c->db,key); + + /* It is possible that even if there are no clients waiting for + * a load operation, still we have a load operation in progress. + * For instance think to a client performing a GET and then + * closing the connection */ + if ((flags & (REDIS_IO_LOAD|REDIS_IO_LOADINPROG)) == 0) + cacheScheduleIO(c->db,key,REDIS_IO_LOAD); + } return 1; } -- 2.47.2