szetszwo commented on code in PR #1096:
URL: https://github.com/apache/ratis/pull/1096#discussion_r1613938740


##########
ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java:
##########
@@ -456,13 +456,17 @@ protected CompletableFuture<Long> 
appendEntryImpl(ReferenceCountedObject<LogEntr
       // to statemachine first and then to the cache. Not following the order
       // will leave a spurious entry in the cache.
       final Task write = fileLogWorker.writeLogEntry(entryRef, 
removedStateMachineData, context);
-      if (stateMachineCachingEnabled && (removedStateMachineData != entry)) {
+      if (stateMachineCachingEnabled) {
         // The stateMachineData will be cached inside the StateMachine itself.
-        cache.appendEntry(LogSegment.Op.WRITE_CACHE_WITH_STATE_MACHINE_CACHE,
-            ReferenceCountedObject.wrap(removedStateMachineData));
+        if ((removedStateMachineData != entry)) {

Review Comment:
   There are double parenthesis, i.e. `((...))`



##########
ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java:
##########
@@ -456,13 +456,17 @@ protected CompletableFuture<Long> 
appendEntryImpl(ReferenceCountedObject<LogEntr
       // to statemachine first and then to the cache. Not following the order
       // will leave a spurious entry in the cache.
       final Task write = fileLogWorker.writeLogEntry(entryRef, 
removedStateMachineData, context);
-      if (stateMachineCachingEnabled && (removedStateMachineData != entry)) {
+      if (stateMachineCachingEnabled) {
         // The stateMachineData will be cached inside the StateMachine itself.
-        cache.appendEntry(LogSegment.Op.WRITE_CACHE_WITH_STATE_MACHINE_CACHE,
-            ReferenceCountedObject.wrap(removedStateMachineData));
+        if ((removedStateMachineData != entry)) {
+          cache.appendEntry(LogSegment.Op.WRITE_CACHE_WITH_STATE_MACHINE_CACHE,
+              ReferenceCountedObject.wrap(removedStateMachineData));
+        } else {
+          cache.appendEntry(LogSegment.Op.WRITE_CACHE_WITH_STATE_MACHINE_CACHE,
+              ReferenceCountedObject.wrap(LogProtoUtils.copy(entry)));

Review Comment:
   It should copy `removedStateMachineData` instead.



-- 
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: issues-unsubscr...@ratis.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to