]> git.kaiwu.me - nginx.git/commitdiff
Cache: fixed race in ngx_http_file_cache_forced_expire().
authorMaxim Dounin <mdounin@mdounin.ru>
Tue, 1 Feb 2022 13:29:28 +0000 (16:29 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Tue, 1 Feb 2022 13:29:28 +0000 (16:29 +0300)
During configuration reload two cache managers might exist for a short
time.  If both tried to delete the same cache node, the "ignore long locked
inactive cache entry" alert appeared in logs.  Additionally,
ngx_http_file_cache_forced_expire() might be also called by worker
processes, with similar results.

Fix is to ignore cache nodes being deleted, similarly to how it is
done in ngx_http_file_cache_expire() since 3755:76e3a93821b1.  This
was somehow missed in 7002:ab199f0eb8e8, when ignoring long locked
cache entries was introduced in ngx_http_file_cache_forced_expire().

src/http/ngx_http_file_cache.c

index c40093bca61cbd199c0c06e85640614f85241c8b..4d2f6c42c70e69d686e361794b6223e562b01286 100644 (file)
@@ -1756,6 +1756,11 @@ ngx_http_file_cache_forced_expire(ngx_http_file_cache_t *cache)
             break;
         }
 
+        if (fcn->deleting) {
+            wait = 1;
+            break;
+        }
+
         p = ngx_hex_dump(key, (u_char *) &fcn->node.key,
                          sizeof(ngx_rbtree_key_t));
         len = NGX_HTTP_CACHE_KEY_LEN - sizeof(ngx_rbtree_key_t);