You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2024/04/16 09:25:52 UTC

[Bug 68901] New: Coyote is hardcoded to drop connections on 400|408|411|414|500|503|501 which should be configurable for application level errors to prevent expensive TLS handshake/resumption on reconnect

https://bz.apache.org/bugzilla/show_bug.cgi?id=68901

            Bug ID: 68901
           Summary: Coyote is hardcoded to drop connections on
                    400|408|411|414|500|503|501 which should be
                    configurable for application level errors to prevent
                    expensive TLS handshake/resumption on reconnect
           Product: Tomcat 10
           Version: unspecified
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Connectors
          Assignee: dev@tomcat.apache.org
          Reporter: alessandro.vermeulen@ing.com
  Target Milestone: ------

Overview:

Currently Coyote is hardcoded to drop connections when a request generates a
response with one of the following status codes:  400|408|411|414|500|503|501.
This behaviour has been around for at least 15 years and has been copied from
Apache HTTPd[1]. It makes sense in case the server itself is the origin of the
error responses.

However, in our case we have plenty of scenarios we have applications returning
generic 500 responses on generic errors, causing connections to drop and
subsequent reconnects. Status codes 503 and 501 also seem to cases which should
be handled just fine without needing to reset the connection.

We terminate TLS in the application where even session resumption is expensive
and a full TLS handshake is even more expensive. 

Together with Tomcat dropping the connections on 500 errors this leads to
cascade failures where spurious load-related errors cause a spike in CPU usage
which can trigger further errors, further consuming CPU until most CPU is used
to handle TLS connections instead of actual value.

We suggest to make the the behaviour to drop connections is configurable.
Either to completely disable it, or to make the status codes configurable.

[1]:
https://github.com/apache/tomcat/blame/bc900e0100de9879604b93af4722c272ab3d1a24/java/org/apache/coyote/http11/Http11Processor.java#L604-L617
```
    /**
     * Determine if we must drop the connection because of the HTTP status
code. Use the same list of codes as
     * Apache/httpd.
     */
    private static boolean statusDropsConnection(int status) {
        return status == 400 /* SC_BAD_REQUEST */ || status == 408 /*
SC_REQUEST_TIMEOUT */ ||
                status == 411 /* SC_LENGTH_REQUIRED */ || status == 413 /*
SC_REQUEST_ENTITY_TOO_LARGE */ ||
                status == 414 /* SC_REQUEST_URI_TOO_LONG */ || status == 500 /*
SC_INTERNAL_SERVER_ERROR */ ||
                status == 503 /* SC_SERVICE_UNAVAILABLE */ || status == 501 /*
SC_NOT_IMPLEMENTED */;
    }
```

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 68901] Coyote is hardcoded to drop connections on 400|408|411|414|500|503|501 which should be configurable for application level errors to prevent expensive TLS handshake/resumption on reconnect

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=68901

--- Comment #3 from Christopher Schultz <ch...@christopherschultz.net> ---
I think it's reasonable for Tomcat to drop the connection if it *knows* that
the connection is broken e.g. Tomcat has detected malformed headers, trailers,
etc.

But if Tomcat hands-off control to the application and the application
generates a 4xx response, etc. then I think it makes sense to allow the
connection to remain open for subsequent pipelined requests.

A case I'm not so sure about is when the application will be consuming the
request and so Tomcat doesn't "know" until later in the request-processing that
the request body is malformed. Think "chunked encoding gone wrong". Tomcat
needs a way to ensure that it can tell the difference between this kind of
situation and one where the application itself has decided to return a 400
response.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 68901] Coyote is hardcoded to drop connections on 400|408|411|414|500|503|501 which should be configurable for application level errors to prevent expensive TLS handshake/resumption on reconnect

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=68901

Tiago do Couto <ti...@docouto.dev> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tiago@docouto.dev

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 68901] Coyote is hardcoded to drop connections on 400|408|411|414|500|503|501 which should be configurable for application level errors to prevent expensive TLS handshake/resumption on reconnect

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=68901

Michael Osipov <mi...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |michaelo@apache.org

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 68901] Coyote is hardcoded to drop connections on 400|408|411|414|500|503|501 which should be configurable for application level errors to prevent expensive TLS handshake/resumption on reconnect

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=68901

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |adwsingh@gmail.com

--- Comment #2 from Mark Thomas <ma...@apache.org> ---
*** Bug 68958 has been marked as a duplicate of this bug. ***

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 68901] Coyote is hardcoded to drop connections on 400|408|411|414|500|503|501 which should be configurable for application level errors to prevent expensive TLS handshake/resumption on reconnect

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=68901

--- Comment #1 from Michael Osipov <mi...@apache.org> ---
I'd like to see this backed by the current RFC if it is a requirement or just
the way Tomcat handles it. Also maybe it might be worth to raise the same issue
with HTTPd as well.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 68901] Coyote is hardcoded to drop connections on 400|408|411|414|500|503|501 which should be configurable for application level errors to prevent expensive TLS handshake/resumption on reconnect

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=68901

Matafagafo <ma...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matafagafo@gmail.com

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org