Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero byte chunked errors are not cached #11313

Open
ezelkow1 opened this issue May 2, 2024 · 2 comments
Open

Zero byte chunked errors are not cached #11313

ezelkow1 opened this issue May 2, 2024 · 2 comments
Labels
Milestone

Comments

@ezelkow1
Copy link
Member

ezelkow1 commented May 2, 2024

Had a customer issue and started trying to reproduce it here and finally could using proxy verifier as an origin. If you return an error response, say 404, and have negative caching enabled for 404's, but then have the origin return that error as a chunked response with a 0 byte body then it is not actually cached or negative cached.

So there seems to be an issue with chunking and 0 byte responses

@ezelkow1 ezelkow1 added the Bug label May 2, 2024
@bneradt
Copy link
Contributor

bneradt commented May 2, 2024

This can be reproduced using the negative-caching autest via this patch:

diff --git a/tests/gold_tests/cache/replay/negative-caching-300-second-timeout.replay.yaml b/tests/gold_tests/cache/replay/negative-caching-300-second-timeout.replay.yaml
index 7cb667b5e..a5cd7363b 100644
--- a/tests/gold_tests/cache/replay/negative-caching-300-second-timeout.replay.yaml
+++ b/tests/gold_tests/cache/replay/negative-caching-300-second-timeout.replay.yaml
@@ -52,8 +52,10 @@ sessions:
       reason: "Not Found"
       headers:
         fields:
-        - [ Content-Length, 32 ]
+        - [ Transfer-Encoding, chunked ]
         - [ Cache-Control, max-age=300 ]
+      content:
+        size: 0
 
     proxy-response:
       status: 404

Test output:

$  ./autest.sh --sandbox /tmp/sb --clean=none -f negative-caching                                                                                                                                                                                                                                               
Running Test negative-caching:......F Failed                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                                                  
Generating Report: --------------                                                                                                                                                                                                                                                                                 
 Test: negative-caching: Failed    
...
   Run: Add a 404 response with explicit max-age=300 to the cache: Failed
     Test : Checking that True == _isRunningAfter - Passed
        Reason: Returned Value: True == _isRunningAfter
     Starting TestRun 6-tr : No Issues found - Passed
        Reason: Started!
     Process: server-lifetime-cc: Passed
       Setting up : Copying '/home/bneradt/src/ts_asf_master_negative_caching_chunked_body/build/proxy-verifier-v2.10.1/linux-arm64' to '/tmp/sb/negative-caching/server-lifetime-cc/bin' - Passed
       Setting up : recycling port: 61038, queue size: 965 - Passed
       Setting up : recycling port: 61039, queue size: 964 - Passed
       Setting up : recycling port: 61040, queue size: 963 - Passed
       Setting up : Copying '/home/bneradt/src/ts_asf_master_negative_caching_chunked_body/tests/gold_tests/autest-site/../../tools/proxy-verifier/ssl/server.pem' to '/tmp/sb/negative-caching/server-lifetime-cc/server.pem' - Passed
       Setting up : Copying '/home/bneradt/src/ts_asf_master_negative_caching_chunked_body/tests/gold_tests/autest-site/../../tools/proxy-verifier/ssl/ca.pem' to '/tmp/sb/negative-caching/server-lifetime-cc/ca.pem' - Passed
       Setting up : Copying 'replay/negative-caching-300-second-timeout.replay.yaml' to '/tmp/sb/negative-caching/server-lifetime-cc/negative-caching-300-second-timeout.replay.yaml' - Passed
       Test : Checking that ReturnCode == 0 - Passed
          Reason: Returned Value: 0 == 0
       file /tmp/sb/negative-caching/_output/6-tr-server-lifetime-cc/stream.stdout.txt : There should be no Proxy Verifier violation errors. - Passed
          Reason: Contents of /tmp/sb/negative-caching/_output/6-tr-server-lifetime-cc/stream.stdout.txt excludes expression
     Process: Default: Failed
       Setting up : Copying '/home/bneradt/src/ts_asf_master_negative_caching_chunked_body/build/proxy-verifier-v2.10.1/linux-arm64' to '/tmp/sb/negative-caching/client-lifetime-cc/bin' - Passed
       Setting up : Copying 'replay/negative-caching-300-second-timeout.replay.yaml' to '/tmp/sb/negative-caching/client-lifetime-cc/negative-caching-300-second-timeout.replay.yaml' - Passed
       Setting up : Copying '/home/bneradt/src/ts_asf_master_negative_caching_chunked_body/tests/gold_tests/autest-site/../../tools/proxy-verifier/ssl/client.pem' to '/tmp/sb/negative-caching/client-lifetime-cc/client.pem' - Passed
       Setting up : Copying '/home/bneradt/src/ts_asf_master_negative_caching_chunked_body/tests/gold_tests/autest-site/../../tools/proxy-verifier/ssl/ca.pem' to '/tmp/sb/negative-caching/client-lifetime-cc/ca.pem' - Passed
       Test : Checking that ReturnCode == 0 - Failed
          Reason: Returned Value 1 != 0
       file /tmp/sb/negative-caching/_output/6-tr-Default/stream.stdout.txt : There should be no Proxy Verifier violation errors. - Failed
          Reason: Contents of /tmp/sb/negative-caching/_output/6-tr-Default/stream.stdout.txt contains expression: "Violation|Invalid status"
             Details:
                     [ERROR]: HTTP/1 Status Violation: expected 404 got 200, key: 22 : 49
   Run: Wait for cached object to be stale if lifetime is incorrectly used.: Skipped
      Reason: Test run 6-tr failed
   Run: Make sure object is fresh: Skipped
      Reason: Test run 6-tr failed

Total of 1 test
  Unknown: 0
  Exception: 0
  Failed: 1
  Warning: 0
  Skipped: 0
  Passed: 0

@bneradt
Copy link
Contributor

bneradt commented May 2, 2024

I notice that this seems to also be an issue for non-negative responses as well. That is, if I modify the Proxy Verifier origin to return a 200 OK with a 0 byte chunked body, a second request for that same object also doesn't get served out of cache either.

@bneradt bneradt changed the title Zero byte chunked errors are not negative cached Zero byte chunked errors are not cached May 3, 2024
@bryancall bryancall added this to the 10.1.0 milestone May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants