From: Vladimír Čunát Date: Tue, 18 Aug 2020 09:34:43 +0000 (+0200) Subject: utils/cache_gc: tolerate ESPACE unless twice in a row X-Git-Tag: v5.1.3~1^2~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a98f8abd658cf5cd065300f2fb24f52ef590207f;p=thirdparty%2Fknot-resolver.git utils/cache_gc: tolerate ESPACE unless twice in a row In the unlikely case that GC happens "too late", it could fail when deleting, in which case it seems best to reopen the cache and try again, as it will probably be deleted by a kresd instance by the next interval. --- diff --git a/utils/cache_gc/kr_cache_gc.c b/utils/cache_gc/kr_cache_gc.c index 71b96bbde..b4ef97993 100644 --- a/utils/cache_gc/kr_cache_gc.c +++ b/utils/cache_gc/kr_cache_gc.c @@ -284,6 +284,10 @@ int kr_cache_gc(kr_cache_gc_cfg_t *cfg, kr_cache_gc_state_t **state) case KNOT_ENOENT: already_gone++; break; + case KNOT_ESPACE: + printf("Warning: out of space, bailing out to retry later.\n"); + api->txn_abort(&txn); + goto finish; default: printf("Warning: skipping deletion because of error (%s)\n", knot_strerror(ret)); diff --git a/utils/cache_gc/main.c b/utils/cache_gc/main.c index 45a18765c..a2c05489f 100644 --- a/utils/cache_gc/main.c +++ b/utils/cache_gc/main.c @@ -134,10 +134,21 @@ int main(int argc, char *argv[]) int exit_code = 0; kr_cache_gc_state_t *gc_state = NULL; + bool last_espace = false; do { int ret = kr_cache_gc(&cfg, &gc_state); + + /* Let's tolerate ESPACE unless twice in a row. */ + if (ret == KNOT_ESPACE) { + if (!last_espace) + ret = KNOT_EOK; + last_espace = true; + } else { + last_espace = false; + } + // ENOENT: kresd may not be started yet or cleared the cache now - if (ret && ret != -ENOENT) { + if (ret && ret != KNOT_ENOENT) { printf("Error (%s)\n", knot_strerror(ret)); exit_code = 10; break;