summaryrefslogtreecommitdiff
path: root/crawler.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2017-06-27 12:17:59 -0700
committerdormando <dormando@rydia.net>2019-09-17 02:37:15 -0700
commitb5ea90160579ba060b8e1d269595b3ec5d77d740 (patch)
tree96d5dc43912f32b4d48d6a19cf161052e9aaa137 /crawler.c
parent554b56687a19300a75ec24184746b5512580c819 (diff)
downloadmemcached-b5ea90160579ba060b8e1d269595b3ec5d77d740.tar.gz
restartable cache
"-e /path/to/tmpfsmnt/file" SIGUSR1 for graceful stop restart requires the same memory limit, slab sizes, and some other infrequently changed details. Most other options and features can change between restarts. Binary can be upgraded between restarts. Restart does some fixup work on start for every item in cache. Can take over a minute with more than a few hundred million items in cache. Keep in mind when a cache is down it may be missing invalidations, updates, and so on.
Diffstat (limited to 'crawler.c')
-rw-r--r--crawler.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/crawler.c b/crawler.c
index b5006a7..eaaf9a5 100644
--- a/crawler.c
+++ b/crawler.c
@@ -460,23 +460,27 @@ static void *item_crawler_thread(void *arg) {
pthread_mutex_unlock(&lru_crawler_lock);
if (settings.verbose > 2)
fprintf(stderr, "LRU crawler thread stopping\n");
+ settings.lru_crawler = false;
return NULL;
}
static pthread_t item_crawler_tid;
-int stop_item_crawler_thread(void) {
+int stop_item_crawler_thread(bool wait) {
int ret;
pthread_mutex_lock(&lru_crawler_lock);
+ if (do_run_lru_crawler_thread == 0) {
+ pthread_mutex_unlock(&lru_crawler_lock);
+ return 0;
+ }
do_run_lru_crawler_thread = 0;
pthread_cond_signal(&lru_crawler_cond);
pthread_mutex_unlock(&lru_crawler_lock);
- if ((ret = pthread_join(item_crawler_tid, NULL)) != 0) {
+ if (wait && (ret = pthread_join(item_crawler_tid, NULL)) != 0) {
fprintf(stderr, "Failed to stop LRU crawler thread: %s\n", strerror(ret));
return -1;
}
- settings.lru_crawler = false;
return 0;
}
@@ -584,6 +588,11 @@ int lru_crawler_start(uint8_t *ids, uint32_t remaining,
STATS_LOCK();
is_running = stats_state.lru_crawler_running;
STATS_UNLOCK();
+ if (do_run_lru_crawler_thread == 0) {
+ pthread_mutex_unlock(&lru_crawler_lock);
+ return -2;
+ }
+
if (is_running &&
!(type == CRAWLER_AUTOEXPIRE && active_crawler_type == CRAWLER_AUTOEXPIRE)) {
pthread_mutex_unlock(&lru_crawler_lock);