Log replicated log dataSize changes 63/93263/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 22 Oct 2020 18:10:01 +0000 (20:10 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 22 Oct 2020 18:19:06 +0000 (20:19 +0200)
This is a bit of critical state, make sure we recalculate it atomically
and log its changes.

JIRA: CONTROLLER-1957
Change-Id: I09532384ce5bbaf7218c0ffdb64799541037fafc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/AbstractReplicatedLogImpl.java

index 2662d71..42af150 100644 (file)
@@ -260,12 +260,14 @@ public abstract class AbstractReplicatedLogImpl implements ReplicatedLog {
         snapshottedJournal = null;
         previousSnapshotIndex = -1;
         previousSnapshotTerm = -1;
-        dataSize = 0;
+
         // need to recalc the datasize based on the entries left after precommit.
+        int newDataSize = 0;
         for (ReplicatedLogEntry logEntry : journal) {
-            dataSize += logEntry.size();
+            newDataSize += logEntry.size();
         }
-
+        LOG.trace("{}: Updated dataSize from {} to {}", logContext, dataSize, newDataSize);
+        dataSize = newDataSize;
     }
 
     @Override

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.