duongkame commented on code in PR #1045:
URL: https://github.com/apache/ratis/pull/1045#discussion_r1520542250


##########
ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java:
##########
@@ -284,25 +303,39 @@ record = segment.getLogRecord(index);
       if (record == null) {
         return null;
       }
-      final LogEntryProto entry = 
segment.getEntryFromCache(record.getTermIndex());
+      final ReferenceCountedObject<LogEntryProto> entry = 
segment.getEntryFromCache(record.getTermIndex());
       if (entry != null) {
         getRaftLogMetrics().onRaftLogCacheHit();
+        entry.retain();
         return entry;
       }
     }
 
     // the entry is not in the segment's cache. Load the cache without holding 
the lock.
     getRaftLogMetrics().onRaftLogCacheMiss();
     cacheEviction.signal();
-    return segment.loadCache(record);
+    ReferenceCountedObject<LogEntryProto> loaded = segment.loadCache(record);
+    if (loaded != null) {
+      loaded.retain();
+    }
+    return loaded;

Review Comment:
   think I did. 
https://github.com/apache/ratis/pull/1045/commits/1414bd63fd10ea27aa9699c71bb9d7ebc8dbb803.
   
   Maybe it was pushed after you'd reviewed, sorry.



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