You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "OneSizeFitsQuorum (via GitHub)" <gi...@apache.org> on 2023/03/28 17:16:34 UTC
[GitHub] [iotdb] OneSizeFitsQuorum commented on a diff in pull request #9474: [IOTDB-5738] Retain 2 copies of snapshot
OneSizeFitsQuorum commented on code in PR #9474:
URL: https://github.com/apache/iotdb/pull/9474#discussion_r1150936076
##########
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:
Why not keep the last few snapshots?
--
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