Welcome! Log In Create A New Profile

Advanced

Re: nginx-1.0.4

Maxim Dounin
June 23, 2011 11:04PM
Hello!

On Sat, Jun 18, 2011 at 03:35:31AM +0400, Maxim Dounin wrote:

[...]

> Thank you for details, I was able to reproduce this issue here.
> Key points are:
>
> 1. Existing expired cache entry (i.e. cache updating).
>
> 2. Client abort before nginx was able to receive response header
> from upstream.
>
> 3. Non-cacheable response from upstream.
>
> I'll take a look how to properly fix this.

Please try the attached patch.

Maxim Dounin
# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1308884310 -14400
# Node ID b1a9c139a443797a16e039bdf091b9889fcc8d88
# Parent 1c167244d2fdb064c159012c50a7ae3fd1ed254a
Cache: fix another "stalled cache updating" alert.

The one reported at [1] happens if client closes prematurely connection
before response header was got from upstream and response isn't cacheable.

As such situations are expected to happen on other errors too, teach
ngx_http_upstream_finalize_request() to free cache in such situations.
This is consistent with behaviour for cacheable responses.

[1] http://www.nginx.org/pipermail/nginx/2011-June/027522.html

diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -2031,15 +2031,6 @@ ngx_http_upstream_send_response(ngx_http
c->error = 1;

} else {
-
-#if (NGX_HTTP_CACHE)
-
- if (r->cache) {
- ngx_http_file_cache_free(r->cache, u->pipe->temp_file);
- }
-
-#endif
-
ngx_http_upstream_finalize_request(r, u, rc);
return;
}
@@ -2991,16 +2982,19 @@ ngx_http_upstream_finalize_request(ngx_h

#if (NGX_HTTP_CACHE)

- if (u->cacheable && r->cache) {
- time_t valid;
-
- if (rc == NGX_HTTP_BAD_GATEWAY || rc == NGX_HTTP_GATEWAY_TIME_OUT) {
-
- valid = ngx_http_file_cache_valid(u->conf->cache_valid, rc);
-
- if (valid) {
- r->cache->valid_sec = ngx_time() + valid;
- r->cache->error = rc;
+ if (r->cache) {
+
+ if (u->cacheable) {
+ time_t valid;
+
+ if (rc == NGX_HTTP_BAD_GATEWAY || rc == NGX_HTTP_GATEWAY_TIME_OUT) {
+
+ valid = ngx_http_file_cache_valid(u->conf->cache_valid, rc);
+
+ if (valid) {
+ r->cache->valid_sec = ngx_time() + valid;
+ r->cache->error = rc;
+ }
}
}

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

nginx-1.0.4

Igor Sysoev June 01, 2011 05:36AM

Re: nginx-1.0.4

brunohardhouse June 14, 2011 04:48PM

Re: nginx-1.0.4

Maxim Dounin June 14, 2011 06:14PM

Re: nginx-1.0.4

brunohardhouse June 14, 2011 11:07PM

Re: nginx-1.0.4

Maxim Dounin June 15, 2011 04:00AM

Re: nginx-1.0.4

brunohardhouse June 16, 2011 10:20AM

Re: nginx-1.0.4

Maxim Dounin June 17, 2011 07:36PM

Re: nginx-1.0.4

Maxim Dounin June 23, 2011 11:04PM

Re: nginx-1.0.4

brunohardhouse June 22, 2011 10:24AM

Re: nginx-1.0.4

brunohardhouse June 29, 2011 09:59AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 292
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