Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixed diskstore race condition

  • Loading branch information...
commit 0aed6a952a0acf5a02ec4b588031ec3dc231a68c 1 parent e270a7f
Salvatore Sanfilippo authored March 10, 2011

Showing 1 changed file with 10 additions and 2 deletions. Show diff stats Hide diff stats

  1. 12  src/dscache.c
12  src/dscache.c
@@ -890,8 +890,16 @@ int waitForSwappedKey(redisClient *c, robj *key) {
890 890
     listAddNodeTail(l,c);
891 891
 
892 892
     /* Are we already loading the key from disk? If not create a job */
893  
-    if (de == NULL)
894  
-        cacheScheduleIO(c->db,key,REDIS_IO_LOAD);
  893
+    if (de == NULL) {
  894
+        int flags = cacheScheduleIOGetFlags(c->db,key);
  895
+
  896
+        /* It is possible that even if there are no clients waiting for
  897
+         * a load operation, still we have a load operation in progress.
  898
+         * For instance think to a client performing a GET and then
  899
+         * closing the connection */
  900
+        if ((flags & (REDIS_IO_LOAD|REDIS_IO_LOADINPROG)) == 0)
  901
+            cacheScheduleIO(c->db,key,REDIS_IO_LOAD);
  902
+    }
895 903
     return 1;
896 904
 }
897 905
 

0 notes on commit 0aed6a9

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