You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "wangchao316 (via GitHub)" <gi...@apache.org> on 2023/03/29 06:37:05 UTC

[GitHub] [iotdb] wangchao316 commented on a diff in pull request #9475: [To rel/1.1][IOTDB-5738] Retain 2 copies of snapshot

wangchao316 commented on code in PR #9475:
URL: https://github.com/apache/iotdb/pull/9475#discussion_r1151455311


##########
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:
   The modification code and master branch are different. why?



-- 
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: reviews-unsubscribe@iotdb.apache.org

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