Bug 48400

Summary: HTTP Post Request is set to recoverable on timeout waiting for response from tomcat
Product: Tomcat Connectors Reporter: Sudhir Reddy <discoversudhir>
Component: mod_jkAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED WONTFIX    
Severity: major CC: p.mouawad
Priority: P2    
Version: 1.2.28   
Target Milestone: ---   
Hardware: PC   
OS: Linux   

Description Sudhir Reddy 2009-12-16 21:21:05 UTC
mod_jk retries http post requests in case of timeout in getting response from tomcat with default configurations(no retries or recovery_options specified).

AFAIK HTTP Get and Head requests are only considered idempotent, shouldn't post requests be non-recoverable ?

We are using apache <--> mod_jk-1.2.28 <--AJP13--> tomcat
We also are using DisableReuse flag in mod_jk config

I understand this can be fixed with disabling the recovery option.

Wondering if its a default config issue or a bug in mod_jk.
If it is intentional can someone please explain the intention ?

mod_jk logs :
----------------------------
[Tue Dec 15 05:53:50 2009] [13935:0] [debug] init_ws_service::mod_jk.c (935): Service protocol=HTTP/1.1 method=POST
ssl=true host=(null) addr=XXXXXXXX name=XXXXXXXXX port=XXXX auth=(null)
user=(null) laddr=XXXXXXXX raddr=XXXXXXXX uri=/XXXXXXXXXXXX-MASKING--XXXX

[Tue Dec 15 05:53:50 2009] [13935:0] [debug] jk_open_socket::jk_connect.c (541): timeout 120 set for socket=43
[Tue Dec 15 05:53:50 2009] [13935:0] [debug] jk_open_socket::jk_connect.c (576): trying to connect socket 43 to
127.0.0.1:8009
[Tue Dec 15 05:53:50 2009] [13935:0] [debug] jk_open_socket::jk_connect.c (602): socket 43 connected to 127.0.0.1:8009
[Tue Dec 15 05:53:50 2009] [13935:0] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1070): sending to ajp13
pos=4 len=2495 max=8192


After 2 mins ........


[Tue Dec 15 05:55:50 2009] [13935:0] [debug] jk_shutdown_socket::jk_connect.c (681): About to shutdown socket 43
[Tue Dec 15 05:55:52 2009] [13935:0] [debug] jk_shutdown_socket::jk_connect.c (732): Shutdown socket 43 and read 0
lingering bytes
[Tue Dec 15 05:55:52 2009] [13935:0] [info] ajp_connection_tcp_get_message::jk_ajp_common.c (1150): (consWorker) can't
receive the response header message from tomcat, network problems or tomcat (127.0.0.1:8009) is down (errno=11)
[Tue Dec 15 05:55:52 2009] [13935:0] [error] ajp_get_reply::jk_ajp_common.c (1962): (consWorker) Tomcat is down or
refused connection. No response has been sent to the client (yet)
[Tue Dec 15 05:55:52 2009] [13935:0] [info] ajp_service::jk_ajp_common.c (2447): (consWorker) sending request to tomcat
failed (recoverable),  (attempt=1)
[Tue Dec 15 05:55:52 2009] [13935:0] [debug] ajp_service::jk_ajp_common.c (2304): retry 1, sleeping for 100 ms before
retrying
[Tue Dec 15 05:55:53 2009] [13935:0] [debug] ajp_send_request::jk_ajp_common.c (1501): (consWorker) all endpoints are
disconnected.
[Tue Dec 15 05:55:53 2009] [13935:0] [debug] jk_open_socket::jk_connect.c (452): socket TCP_NODELAY set to On
[Tue Dec 15 05:55:53 2009] [13935:0] [debug] jk_open_socket::jk_connect.c (541): timeout 120 set for socket=43
[Tue Dec 15 05:55:53 2009] [13935:0] [debug] jk_open_socket::jk_connect.c (576): trying to connect socket 43 to
127.0.0.1:8009
[Tue Dec 15 05:55:53 2009] [13935:0] [debug] jk_open_socket::jk_connect.c (602): socket 43 connected to 127.0.0.1:8009
[Tue Dec 15 05:55:53 2009] [13935:0] [debug] ajp_connect_to_endpoint::jk_ajp_common.c (931): Connected socket 43 to
(127.0.0.1:8009)
[Tue Dec 15 05:55:53 2009] [13935:0] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1070): sending to ajp13
pos=4 len=2495 max=8192
----------------------------
Comment 1 Rainer Jung 2009-12-17 02:26:04 UTC
(In reply to comment #0)

> I understand this can be fixed with disabling the recovery option.
> 
> Wondering if its a default config issue or a bug in mod_jk.

Default config issue. It should have been "don't retry POST by default", but for compatibility reasons the wrong defaults chosen once were never changed during 1.2.x. This will be kept as is and only change for the next "major" version 1.3. For that we will change a lot of configuration options to more sensble defaults.
Comment 2 Philippe Mouawad 2014-09-05 12:22:58 UTC
Hello Rainer,
Can those better defaults be found somewhere ? I looked at svn branch 1.3 but only found ROADMAP.

Regarding "don't retry POST by default",
Can this be configured by setting: 
recovery_options=27


Thanks
Comment 3 Rainer Jung 2014-09-06 10:48:39 UTC
Hi Philippe,

look for workers.properties (*not* the "minimal" one) and httpd-jk.conf in http://svn.apache.org/viewvc/tomcat/jk/trunk/conf/ or in the conf/ directory of every released source archive download (starting many years ago).

For recovery_options, yes, "3" or "27" are reasonable defaults. See http://tomcat.apache.org/connectors-doc/reference/workers.html.

Please post further questions to the appropriate Tomcat mailing list (mostly the users list), not here.
Comment 4 Philippe Mouawad 2014-09-07 13:49:31 UTC
Thanks a lot for answers Rainer.
I thought it might be interesting to ask here so that other users can find the answer in the related issue.