Welcome! Log In Create A New Profile

Advanced

[nginx] Cache: keep c->body_start when Vary changes (ticket #2029).

Sergey Kandaurov
September 11, 2020 03:18PM
details: https://hg.nginx.org/nginx/rev/3781de64e747
branches:
changeset: 7705:3781de64e747
user: Sergey Kandaurov <pluknet@nginx.com>
date: Wed Sep 09 19:26:27 2020 +0300
description:
Cache: keep c->body_start when Vary changes (ticket #2029).

If the variant hash doesn't match one we used as a secondary cache key,
we switch back to the original key. In this case, c->body_start was kept
updated from an existing cache node overwriting the new response value.
After file cache update, it led to discrepancy between a cache node and
cache file seen as critical errors "file cache .. has too long header".

diffstat:

src/http/ngx_http_cache.h | 1 +
src/http/ngx_http_file_cache.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)

diffs (31 lines):

diff -r 847fd35f94de -r 3781de64e747 src/http/ngx_http_cache.h
--- a/src/http/ngx_http_cache.h Fri Aug 04 19:37:37 2017 +0300
+++ b/src/http/ngx_http_cache.h Wed Sep 09 19:26:27 2020 +0300
@@ -117,6 +117,7 @@ struct ngx_http_cache_s {
unsigned purged:1;
unsigned reading:1;
unsigned secondary:1;
+ unsigned update_variant:1;
unsigned background:1;

unsigned stale_updating:1;
diff -r 847fd35f94de -r 3781de64e747 src/http/ngx_http_file_cache.c
--- a/src/http/ngx_http_file_cache.c Fri Aug 04 19:37:37 2017 +0300
+++ b/src/http/ngx_http_file_cache.c Wed Sep 09 19:26:27 2020 +0300
@@ -854,7 +854,7 @@ ngx_http_file_cache_exists(ngx_http_file
if (fcn->exists || fcn->uses >= c->min_uses) {

c->exists = fcn->exists;
- if (fcn->body_start) {
+ if (fcn->body_start && !c->update_variant) {
c->body_start = fcn->body_start;
}

@@ -1339,6 +1339,7 @@ ngx_http_file_cache_update_variant(ngx_h
ngx_shmtx_unlock(&cache->shpool->mutex);

c->file.name.len = 0;
+ c->update_variant = 1;

ngx_memcpy(c->key, c->main, NGX_HTTP_CACHE_KEY_LEN);

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Cache: keep c->body_start when Vary changes (ticket #2029).

Sergey Kandaurov 330 September 11, 2020 03:18PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 210
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready