davsclaus commented on code in PR #30368:
URL: https://github.com/apache/camel/pull/30368#discussion_r4626283721


##########
components/camel-redis/src/main/java/org/apache/camel/component/redis/processor/aggregate/RedisAggregationRepository.java:
##########
@@ -477,13 +529,46 @@ protected void doStart() throws Exception {
             }
         }
 
-        cache = redisson.getMap(mapName);
+        cache = redisson.getMap(mapName, CODEC);
+        warnUnreadableEntries(cache, mapName);
 
         if (useRecovery) {
-            persistedCache = redisson.getMap(persistenceMapName);
+            persistedCache = redisson.getMap(persistenceMapName, CODEC);
+            warnUnreadableEntries(persistedCache, persistenceMapName);
         }
     }
 
+    /**
+     * Logs a WARN when the hash has entries that are not serialized 
exchanges, such as the entries stored by an older
+     * version of this repository, which are not read. Only the first bytes of 
each value are checked.
+     */
+    private void warnUnreadableEntries(RMap<String, byte[]> map, String name) {
+        try {
+            long count = 0;
+            for (Map.Entry<String, byte[]> entry : map.entrySet(SCAN_COUNT)) {

Review Comment:
   The entries are streamed page by page (`entrySet(100)` is an HSCAN iterator) 
and nothing is kept: each value is checked for the two magic bytes and dropped, 
so the heap holds one page at a time, not the whole hash. The cost is reading 
the hash once at start, which is small for aggregation hashes (in-flight 
aggregations only) and similar to what the aggregator already does at start 
with `completionTimeout`. The count is in the WARN so the operator knows how 
much is affected.
   
   _Claude Code on behalf of Claus Ibsen_



##########
components/camel-redis/src/main/java/org/apache/camel/component/redis/processor/aggregate/RedisAggregationRepository.java:
##########
@@ -477,13 +529,46 @@ protected void doStart() throws Exception {
             }
         }
 
-        cache = redisson.getMap(mapName);
+        cache = redisson.getMap(mapName, CODEC);
+        warnUnreadableEntries(cache, mapName);
 
         if (useRecovery) {
-            persistedCache = redisson.getMap(persistenceMapName);
+            persistedCache = redisson.getMap(persistenceMapName, CODEC);
+            warnUnreadableEntries(persistedCache, persistenceMapName);
         }
     }
 
+    /**
+     * Logs a WARN when the hash has entries that are not serialized 
exchanges, such as the entries stored by an older
+     * version of this repository, which are not read. Only the first bytes of 
each value are checked.
+     */
+    private void warnUnreadableEntries(RMap<String, byte[]> map, String name) {
+        try {
+            long count = 0;
+            for (Map.Entry<String, byte[]> entry : map.entrySet(SCAN_COUNT)) {
+                if (!isSerializedObject(entry.getValue())) {
+                    count++;
+                }
+            }
+            if (count > 0) {
+                LOG.warn("The Redis hash {} has entries that are not exchanges 
serialized by this version of"
+                         + " RedisAggregationRepository (count: {}). These 
entries are ignored: entries stored by an"
+                         + " older Camel version are not read. See the 
camel-redis section of the Camel 4.24 upgrade"
+                         + " guide.",
+                        name, count);
+            }
+        } catch (Exception e) {
+            LOG.debug("Cannot check the entries of the Redis hash {}", name, 
e);

Review Comment:
   Done in 64454ce1dd1e (WARN).
   
   _Claude Code on behalf of Claus Ibsen_



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