Opened 5 years ago

Closed 5 years ago

#1801 closed defect (invalid)

Stale cache is not updated after some time

Reported by: patrick.clara@… Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.14.x
Keywords: Cc:
uname -a: Linux webc-g1 4.19.0-0.bpo.5-amd64 #1 SMP Debian 4.19.37-3~bpo9+1 (2019-05-18) x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.14.1
built with OpenSSL 1.1.0f 25 May 2017 (running with OpenSSL 1.1.1b 26 Feb 2019)
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-jqo7Nx/nginx-1.14.1=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_flv_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_secure_link_module --with-http_sub_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-headers-more-filter --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-auth-pam --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-cache-purge --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-dav-ext --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-ndk --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-echo --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-fancyindex --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/nchan --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-lua --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/rtmp --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-uploadprogress --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-upstream-fair --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-subs-filter

Description

I configured a reverse caching proxy which makes use of "proxy_cache_use_stale updating" and "proxy_cache_background_update on".

At first everything seems to work fine, after some time (the day after) i notice that stale caches are not updated.

This is what happens until it works fine:

  1. Client makes the 1. request.
  2. Proxy responds with an updated response from the upstream server and "x-cache-status: MISS".
  3. Client makes the 2. request.
  4. Proxy responds with a cached response and "x-cache-status: HIT".
  5. Client waits 10 min. for the cache to expire and makes the 3. request.
  6. Proxy responds with a cached (and slightly outdated) response and "x-cache-status: STALE".
  7. Proxy is making a request to the upstream server.
  8. Client makes the 4. request.
  9. Proxy responds with a cached (and up to date) response and "x-cache-status: HIT".

After some time, apparently without any changes to the system, the cache breaks:

  1. Client makes the 1. request.
  2. Proxy responds with a cached (and outdated) response and "x-cache-status: STALE".
  3. Proxy is making a request to the upstream server.
  4. Client makes the 2. request.
  5. Proxy responds with a cached (and outdated) response and "x-cache-status: STALE".
  6. Proxy is making a request to the upstream server.
  7. Repeats forever.

At the moment I can not tell exactly how much time it needs to pass for the cache to break. Up to now i noticed a broken cache on the day after. Also I do not know if there is a correlation with the number and time of the requests being made in the meantime.

I attached the nginx configuration and two debug logs of the cache updating fine and not updating.

ps: the upstream server add "x-accel-expire: 600" to the response.

Attachments (4)

nginx_config (1.8 KB ) - added by patrick.clara@… 5 years ago.
main configuration
vhost_config (2.1 KB ) - added by patrick.clara@… 5 years ago.
vhost configuration
cache_updating (178.1 KB ) - added by patrick.clara@… 5 years ago.
debug log when stale cache is updating fine
cache_not_updating (95.0 KB ) - added by patrick.clara@… 5 years ago.
debug log when stale cache is not updated

Download all attachments as: .zip

Change History (6)

by patrick.clara@…, 5 years ago

Attachment: nginx_config added

main configuration

by patrick.clara@…, 5 years ago

Attachment: vhost_config added

vhost configuration

by patrick.clara@…, 5 years ago

Attachment: cache_updating added

debug log when stale cache is updating fine

by patrick.clara@…, 5 years ago

Attachment: cache_not_updating added

debug log when stale cache is not updated

comment:1 by patrick.clara@…, 5 years ago

Please close this ticket. It is not a bug, just my misunderstanding of how things work.
I'm sorry.

comment:2 by Sergey Kandaurov, 5 years ago

Resolution: invalid
Status: newclosed

Close per submitter request.

Note: See TracTickets for help on using tickets.