Skip to content

Presence of Transfer-Encoding and Content-Length headers leads to empty response #7230

Closed

Description

@elsloo

When an object requested through ATS that has both Transfer-Encoding: Chunked and Content-Length headers, ATS appears to assume the object is chunked and follows those code paths accordingly. However, we observed a case on an object (<500 bytes, if relevant) that led the HttpSM to the following location:

https://github.com/apache/trafficserver/blob/8.1.x/proxy/http/HttpSM.cc#L2923

This leads to a successful pssc (200, 206), pfsc=INTR, crc=ERR_READ_ERROR being logged, but an empty reply to the client. No response headers, no error message in the body; nothing. The only way to find the issue was to put ATS into debug, see the error message, then, armed with this knowledge, hunt for the issue. In our case, the Transfer-Encoding should not have been present.

While these headers should be used independently, it happened. If this were to occur in the future, our ideal state would be a real HTTP 5xx error response served to the client instead of nothing, and something more meaningful would be logged such that debug is no longer necessary to find the hint that this is the problem. pfsc=INTR is misleading, because the transaction completed successfully between ATS and the upstream system. Instead, ATS should have logged pfsc=FIN and, if anything, cfsc was INTR but that still is not really descriptive enough to know why the transaction was interrupted/aborted.

The system that served this object to ATS, was, itself, an ATS cache. It was able to successfully cache the object with both headers present, and presumably, the IMS process allowed this condition to remain for a prolonged period of time. A secondary aspect of this issue is that when ATS makes the request itself as a consequence of an ATS client request, it can cache the response and serve it successfully, as far as its logs are concerned. However, the downstream cache, while it is able to fully read the response and the upstream cache logs it as a success, it then aborts the request as described. One could argue that the upstream cache should have generated an error that would have propagated to the downstream cache.

This was found on ATS 8.1.

Activity

  1. elsloo commented on Oct 1, 2020

    @elsloo
    ContributorAuthor

    Update: after further troubleshooting and testing, we now understand the cause of this issue.

    1. Client facing ATS instance receives a request for an object that results in a cache miss
    2. ATS proxies the request to another ATS instance, which is also is a cache miss
    3. ATS proxies the request to the origin, receives a 200 OK and the object, fills its cache and returns the object
    4. Client facing ATS receives this object and returns it to the client

    n seconds later per Cache-Control: max-age, the object is revalidated by the ATS cache in front of the origin following a similar sequence:

    1. Client facing ATS instance receives a request for an object that results in a cache miss
    2. ATS proxies the request to another ATS instance that has the object in cache but it must be revalidated
    3. ATS sends an IMS request to the origin, receives and a 304 Not Modified, however:
      • The origin also appends a Transfer-Encoding: chunked header that is merged into the cached headers
      • The origin doesn't send an accompanying 0\r\n chunk with the response
    4. Client facing ATS receives the object from the upstream ATS cache with both a Content-Length and Transfer-Encoding header and the full body, but the chunk handling fails and lands in the block linked above and aborts the client's request

    The origin's response appears to violate the intended use of Transfer-Encoding: chunked but the ATS cache that receives that response as a result of an IMS doesn't notice and caches the additional header. When that object is attempted to be served from that cache any time in the future, both headers are served, and the downstream ATS hosts are thrown off by the Transfer-Encoding: chunked header and lack of chunked response. For what it's worth, curl similarly gets confused by the presence of both headers.

  2. github-actions commented on Oct 2, 2021

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity. Marking it stale to flag it for further consideration by the community.

  3. bneradt commented on Dec 7, 2021

    @bneradt
    Contributor

    @elsloo : can you please verify whether this is still an issue? I believe we no longer cache the Transfer-Encoding header and this should be fine.

  4. elsloo commented on Dec 7, 2021

    @elsloo
    ContributorAuthor

    This likely should have been closed via #7234. I don't believe this case applies since the introduction of that change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions