FrankChen021 commented on code in PR #20255:
URL: https://github.com/apache/druid/pull/20255#discussion_r3940642339


##########
processing/src/main/java/org/apache/druid/query/cache/CacheKeyBuilder.java:
##########
@@ -323,7 +327,7 @@ public byte[] build()
     buffer.put(id);
 
     for (Item item : items) {
-      buffer.put(item.typeKey).put(item.item);
+      buffer.put(item.typeKey).putInt(item.item.length).put(item.item);

Review Comment:
   [P1] Version the new cache-key format
   
   This changes the serialized bytes for every CacheKeyBuilder key, but the 
output still uses only the caller-supplied id and does not distinguish the new 
format from the old one. During a rolling upgrade, shared caches such as 
Memcached can retain old entries; the two formats are not disjoint, so a new 
key can be an old-format key for a different public builder sequence (for 
example, old appendByte(0).appendByte(0).appendByteArray(new byte[]{v}) 
produces the same bytes as new appendByte(v) for the same id). That can turn a 
miss into a false hit and return another query's result. Add a format/version 
discriminator or explicitly isolate/invalidate old entries, and add a 
mixed-version collision regression test.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to