SzyWilliam commented on code in PR #9475:
URL: https://github.com/apache/iotdb/pull/9475#discussion_r1151477195
##########
consensus/src/main/java/org/apache/iotdb/consensus/ratis/SnapshotStorage.java:
##########
@@ -166,11 +167,14 @@ public void format() throws IOException {}
@Override
public void cleanupOldSnapshots(SnapshotRetentionPolicy
snapshotRetentionPolicy)
throws IOException {
- Path[] sortedSnapshotDirs = getSortedSnapshotDirPaths();
- if (sortedSnapshotDirs == null || sortedSnapshotDirs.length == 0) {
+ final Path[] sortedSnapshotDirs = getSortedSnapshotDirPaths();
+ if (ArrayUtils.isEmpty(sortedSnapshotDirs)) {
return;
}
- for (int i = 0; i < sortedSnapshotDirs.length - 1; i++) {
+
+ final int retainIndex =
+ snapshotRetentionPolicy.getNumSnapshotsRetained() - 1; // snapshot
rank starts from 0
+ for (int i = retainIndex; i < sortedSnapshotDirs.length - 1; i++) {
Review Comment:
Fixed. Now they are the same. Thanks!
--
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]