You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Terence Haddock <la...@tripi.com> on 2002/09/17 18:58:35 UTC

POST bug during Tomcat failover

I posted a bug about failures with POSTs when tomcat fails over, and I
believe I understand where the problem occurs, but not really what is
causing the problem. However, I have figured out a work-around, but the
work-around has some drawbacks. The bug is #12694. The basic idea is
with two Tomcat processes, if you shut down one of the Tomcats, most
POST requests redirected to the other Tomcat fail because no POST data
is sent to the Tomcat server.

I think the problem is in the recovery of the POST data. Basically, when
the request is sent from Apache to Tomcat, the AJP connector sends first
the header data, then it sends the POST content all at once (all data
less than 8k). The POST data is read from the client browser at this
time. In a failover situation, for some reason I have not figured out
yet, when the connection is re-tried the POST data is empty (see the
tcpdump trace in the bug). I hacked the code to not read any POST data
from the browser until Tomcat asks for the data, like this:

diff -c -r1.29 jk_ajp_common.c
*** common/jk_ajp_common.c      4 Sep 2002 11:31:32 -0000       1.29
--- common/jk_ajp_common.c      17 Sep 2002 17:04:20 -0000
***************
*** 898,903 ****
--- 898,904 ----
           * doing a read (not yet) 
           */
          if (s->is_chunked || ae->left_bytes_to_send > 0) {
+ #if 0
              int len = ae->left_bytes_to_send;
              if (len > AJP13_MAX_SEND_BODY_SZ) 
                  len = AJP13_MAX_SEND_BODY_SZ;
***************
*** 906,911 ****
--- 907,914 ----
                  op->recoverable = JK_FALSE;
                  return JK_FALSE;
              }
+ #endif
+             int len = 0;
              s->content_read = len;
              if (!ajp_connection_tcp_send_message(ae, op->post, l)) {
                  jk_log(l, JK_LOG_ERROR, "Error sending request
body\n");

-------------

In other words, always sending a zero length POST content at first,
Tomcat will ask for the data when it needs it. Of course, this is very
inefficient, but I'd rather be inefficient then broken.

There should be a better way to fix this problem, but I do not know the
code enough to fix it myself. Can anyone give any insights into this
issue?

Sincerely,
Terence Haddock


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>