}
}
if (best == NULL) {
- /* Was not able to fix a single object... we should check if our
+ /* Not able to free a single object? we should check if our
* IO queues have stuff in queue, and try to consume the queue
* otherwise we'll use an infinite amount of memory if changes to
* the dataset are faster than I/O */
return REDIS_OK;
}
-/* Return true if it's safe to swap out objects in a given moment.
- * Basically we don't want to swap objects out while there is a BGSAVE
- * or a BGAEOREWRITE running in backgroud. */
-int dsCanTouchDiskStore(void) {
- return (server.bgsavechildpid == -1 && server.bgrewritechildpid == -1);
-}
-
/* ==================== Disk store negative caching ========================
*
* When disk store is enabled, we need negative caching, that is, to remember
}
cacheScheduleIODelFlag(j->db,j->key,REDIS_IO_LOADINPROG);
handleClientsBlockedOnSwappedKey(j->db,j->key);
- freeIOJob(j);
} else if (j->type == REDIS_IOJOB_SAVE) {
cacheScheduleIODelFlag(j->db,j->key,REDIS_IO_SAVEINPROG);
- freeIOJob(j);
}
+ freeIOJob(j);
processed++;
if (privdata == NULL) cacheScheduleIOPushJobs(0);
if (processed == toprocess) return;
redisLog(REDIS_DEBUG,"Queued IO Job %p type %d about key '%s'\n",
(void*)j, j->type, (char*)j->key->ptr);
listAddNodeTail(server.io_newjobs,j);
- if (server.io_active_threads < server.vm_max_threads)
- spawnIOThread();
}
/* Consume all the IO scheduled operations, and all the thread IO jobs
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;
}