Opened 5 years ago
Closed 5 years ago
#1880 closed defect (duplicate)
nginx should bypass cache if worker failed to allocate node in cache keys zone
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | other | Version: | 1.17.x |
Keywords: | http file cache | Cc: | |
uname -a: | Linux my 4.19.45-nx #500 SMP Thu May 23 00:56:30 KST 2019 x86_64 GNU/Linux | ||
nginx -V: | nginx version: nginx/1.17.2 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' --with-debug |
Description
Copied from https://trac.nginx.org/nginx/ticket/1824
Using http file cache.
Seems that if a worker failed to allocate node in cache keys,
then it tries forcely expire cache and allocate node again.
But at the same time if another worker takes the cache first,
the worker will return 500 error with below log
"could not allocate node in cache keys zone"
I think it would be better just bypassing cache and read data from upstreams, instead of returning 500 error.
I tested simple patch below,
Not sure whether it proper approach
but seems it mitigates symptom.
diff -r e7181cfe9212 src/http/ngx_http_file_cache.c --- a/src/http/ngx_http_file_cache.c Tue Jul 23 15:01:47 2019 +0300 +++ b/src/http/ngx_http_file_cache.c Tue Jul 30 17:07:51 2019 +0900 @@ -299,11 +299,7 @@ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http file cache exists: %i e:%d", rc, c->exists); - if (rc == NGX_ERROR) { - return rc; - } - - if (rc == NGX_AGAIN) { + if (rc == NGX_AGAIN || rc == NGX_ERROR) { return NGX_HTTP_CACHE_SCARCE; }
Note:
See TracTickets
for help on using tickets.
Duplicate of #1824.