amaliujia commented on code in PR #1569:
URL: https://github.com/apache/ratis/pull/1569#discussion_r3892559619


##########
ratis-server/src/main/java/org/apache/ratis/statemachine/impl/SimpleStateMachineStorage.java:
##########
@@ -135,6 +135,14 @@ public void cleanupOldSnapshots(SnapshotRetentionPolicy 
snapshotRetentionPolicy)
       }
     }
 
+    // Backward compatibility: before MD5 files existed, all snapshots counted 
toward
+    // retention. When there are fewer MD5 snapshots than numSnapshotsRetained 
(e.g.
+    // all old snapshots without MD5, or old snapshots mixed with new ones 
after upgrade),
+    // fall back to retaining the newest numSnapshotsRetained snapshots 
regardless of MD5.
+    if (deleteIdx < 0 && allSnapshotFiles.size() > numSnapshotsRetained) {

Review Comment:
   sure. I applied by only checking `deleteIdx == -1` but not `<0`



##########
ratis-server/src/main/java/org/apache/ratis/statemachine/impl/SimpleStateMachineStorage.java:
##########
@@ -135,6 +135,14 @@ public void cleanupOldSnapshots(SnapshotRetentionPolicy 
snapshotRetentionPolicy)
       }
     }
 
+    // Backward compatibility: before MD5 files existed, all snapshots counted 
toward
+    // retention. When there are fewer MD5 snapshots than numSnapshotsRetained 
(e.g.
+    // all old snapshots without MD5, or old snapshots mixed with new ones 
after upgrade),
+    // fall back to retaining the newest numSnapshotsRetained snapshots 
regardless of MD5.
+    if (deleteIdx < 0 && allSnapshotFiles.size() > numSnapshotsRetained) {

Review Comment:
   sure. I applied by only checking `deleteIdx == -1` but not `< 0`



-- 
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]

Reply via email to