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>
(cherry picked from commit
e96021b2e492bbaf7efe0804628bfe055b9733f7)
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