Copilot commented on code in PR #13637:
URL: https://github.com/apache/trafficserver/pull/13637#discussion_r3925687578


##########
src/iocore/cache/CacheVC.cc:
##########
@@ -318,31 +318,45 @@ CacheVC::dead(int /* event ATS_UNUSED */, Event * /*e 
ATS_UNUSED */)
   return EVENT_DONE;
 }
 
-static void
-unmarshal_helper(Doc *doc, Ptr<IOBufferData> &buf, int &okay)
+static bool
+unmarshal_helper(Doc *doc, Ptr<IOBufferData> &buf)
 {
   using UnmarshalFunc              = int(char *buf, int len, RefCountObj 
*block_ref);
   UnmarshalFunc    *unmarshal_func = &HTTPInfo::unmarshal;
   ts::VersionNumber version(doc->v_major, doc->v_minor);
 
-  // introduced by https://github.com/apache/trafficserver/pull/4874, this is 
used to distinguish the doc version
-  // before and after #4847
-  if (version < CACHE_DB_VERSION) {
+  if (version < CACHE_DB_VERSION_HTTPINFO_V24_2) {
     unmarshal_func = &HTTPInfo::unmarshal_v24_1;
   }
 
+  // Objects written by an older version can carry stale well known string 
indices and
+  // presence bits. Repair them only on the MARSHALED to ALIVE transition, 
since an already
+  // ALIVE block may be shared with other readers. All alts of a doc 
transition together, so
+  // the first one answers for the whole header block.
+  bool const needs_wks_fixup = version < CACHE_DB_VERSION && doc->hlen > 0 &&
+                               reinterpret_cast<HTTPCacheAlt 
*>(doc->hdr())->m_magic == CacheAltMagic::MARSHALED;

Review Comment:
   The new compatibility boundary (CACHE_DB_VERSION_HTTPINFO_V24_2) and the 
moved WKS/presence-bit fixup in unmarshal_helper change how older cache objects 
are read, but there’s no regression coverage exercising (1) selecting 
HTTPInfo::unmarshal_v24_1 for <24.2 docs and (2) performing the fixup when an 
older object is unmarshalled from a compressed RAM cache entry 
(MARSHALED->ALIVE transition). Adding a targeted unit test 
(src/iocore/cache/unit_tests) or an AuTest reproducer would help prevent future 
version bumps from silently reintroducing the wrong unmarshaller or stale-index 
behavior.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to