]> git.saurik.com Git - redis.git/commitdiff
handle end of space on device in a better way
authorantirez <antirez@gmail.com>
Tue, 4 Jan 2011 18:03:23 +0000 (19:03 +0100)
committerantirez <antirez@gmail.com>
Tue, 4 Jan 2011 18:03:23 +0000 (19:03 +0100)
src/diskstore.c

index 3e0ad406ffaffcff22ad194be50d82a86aa14be3..7250390eb87d752681912ddb181181babee0a00c 100644 (file)
@@ -191,7 +191,16 @@ int dsSet(redisDb *db, robj *key, robj *val) {
     len = dsKeyToPath(db,buf,key);
     memcpy(buf2,buf,len);
     snprintf(buf2+len,sizeof(buf2)-len,"_%ld_%ld",(long)time(NULL),(long)val);
-    fp = fopen(buf2,"w");
+    while ((fp = fopen(buf2,"w")) == NULL) {
+        if (errno == ENOSPC) {
+            redisLog(REDIS_WARNING,"Diskstore: No space left on device. Please make room and wait 30 seconds for Redis to continue.");
+            sleep(30);
+        } else {
+            redisLog(REDIS_WARNING,"diskstore error opening %s: %s",
+                buf2, strerror(errno));
+            redisPanic("Unrecoverable diskstore error. Exiting.");
+        }
+    }
     if ((retval = rdbSaveKeyValuePair(fp,db,key,val,time(NULL))) == -1)
         return REDIS_ERR;
     fclose(fp);