trafficserver icon indicating copy to clipboard operation
trafficserver copied to clipboard

Log the URL when getting a cache OpenReadHead warning

Open bryancall opened this issue 1 year ago • 3 comments

Log the URL when getting a cache OpenReadHead warning when the content
length header doesn't match the document/object length in cache

bryancall avatar Jul 18 '24 20:07 bryancall

I added that code to 9.2.4 but it crashed. Is there a way to test this code without having to put in production?

I might have wrongly applied the patch:

$ git diff HEAD~1
diff --git a/iocore/cache/CacheRead.cc b/iocore/cache/CacheRead.cc
index 95e8b1838..b858a0d98 100644
--- a/iocore/cache/CacheRead.cc
+++ b/iocore/cache/CacheRead.cc
@@ -1182,8 +1182,11 @@ CacheVC::openReadStartHead(int event, Event *e)
       if (field) {
         uint64_t cl = static_cast<uint64_t>(field->value_get_int64());
         if (cl != doc_len) {
-          Warning("OpenReadHead failed for cachekey %X : alternate content length doesn't match doc_len %" PRId64 " != %" PRId64,
-                  key.slice32(0), cl, doc_len);
+          int url_string_length = 0;
+          const char *url_string = alternate.response_get()->url_get()->string_get_ref(&url_string_length);
+          Warning("OpenReadHead failed for cachekey %X : alternate content length doesn't match doc_len %" PRId64 " != %" PRId64
+                  " url: %.*s",
+                  key.slice32(0), cl, doc_len, url_string_length, url_string);
           CACHE_INCREMENT_DYN_STAT(cache_read_invalid_stat);
           err = ECACHE_BAD_META_DATA;
           goto Ldone;

smalenfant avatar Jul 20 '24 16:07 smalenfant

Should this be using request.url_get()->string_get_ref(&url_string_length); instead of alternate.response_get()->url_get()->string_get_ref(&url_string_length); ?

smalenfant avatar Jul 22 '24 14:07 smalenfant

This pull request 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.

github-actions[bot] avatar Oct 21 '24 02:10 github-actions[bot]

@bryancall you still want this change since its been stale for a while?

ezelkow1 avatar Jan 16 '25 17:01 ezelkow1