Welcome! Log In Create A New Profile

Advanced

[PATCH] Request hang when cache_lock is used in subrequests

Yichun Zhang (agentzh)
October 26, 2013 06:40PM
Hello!

Akos Gyimesi reported a request hang (downstream connections stuck in
the CLOSE_WAIT state forever) regarding use of proxy_cache_lock in
subrequests.

The issue is that when proxy_cache_lock_timeout is reached,
ngx_http_file_cache_lock_wait_handler calls
r->connection->write->handler() directly, but
r->connection->write->handler is (usually) just
ngx_http_request_handler, which simply picks up r->connection->data,
which is *not* necessarily the current (sub)request, so the current
subrequest may never be continued nor finalized, leading to an
infinite request hang.

The following patch fixes this issue for me. Comments welcome!

Thanks!
-agentzh

--- nginx-1.4.3/src/http/ngx_http_file_cache.c 2013-10-08
05:07:14.000000000 -0700
+++ nginx-1.4.3-patched/src/http/ngx_http_file_cache.c 2013-10-26
14:47:56.184041728 -0700
@@ -432,6 +432,7 @@ ngx_http_file_cache_lock_wait_handler(ng
ngx_uint_t wait;
ngx_msec_t timer;
ngx_http_cache_t *c;
+ ngx_connection_t *conn;
ngx_http_request_t *r;
ngx_http_file_cache_t *cache;

@@ -471,7 +472,10 @@ wakeup:

c->waiting = 0;
r->main->blocked--;
- r->connection->write->handler(r->connection->write);
+
+ conn = r->connection;
+ r->write_event_handler(r);
+ ngx_http_run_posted_requests(conn);
}
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Request hang when cache_lock is used in subrequests

Yichun Zhang (agentzh) 857 October 26, 2013 06:40PM

Re: [PATCH] Request hang when cache_lock is used in subrequests

Maxim Dounin 339 November 27, 2014 10:32AM

Re: [PATCH] Request hang when cache_lock is used in subrequests

Yichun Zhang (agentzh) 251 November 29, 2014 12:40AM

Re: [PATCH] Request hang when cache_lock is used in subrequests

Maxim Dounin 297 December 01, 2014 10:00PM



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

Online Users

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