amaliujia opened a new pull request, #1569:
URL: https://github.com/apache/ratis/pull/1569

   ## What changes were proposed in this pull request?
   
   Follow-up to #1320 (RATIS-244), which changed 
SimpleStateMachineStorage.cleanupOldSnapshots to count only snapshots with MD5 
files toward the retention limit.
   
   Meanwhile RATIS-244 maintained the backward compatibility for 
`findLatestSnapshot`.
   
   That change broke backward compatibility during upgrades where old snapshots 
(created before MD5 support, without .md5 files) coexist with new snapshots 
(with MD5 files) or there is no new snapshots (with MD5 files). In those cases, 
cleanup could either skip deletion entirely or retain the wrong set of 
snapshots, because old snapshots were excluded from the retention count even 
though they were valid before the upgrade.
   
   This PR restores the original retention behavior as a fallback: when fewer 
than numSnapshotsRetained MD5 snapshots are found, retain the newest 
numSnapshotsRetained snapshots regardless of whether they have MD5 files. This 
covers:
   
   1. All old snapshots without MD5 — retention policy applies as it did before 
RATIS-244
   2. Mixed old and new snapshots after upgrade — old snapshots count toward 
retention when there are not enough new MD5 snapshots to fill the quota
   3. When enough MD5 snapshots exist, the RATIS-244 behavior is unchanged: 
retention is based on MD5 snapshots, and snapshots without MD5 that fall beyond 
that cutoff are still cleaned up.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/RATIS-244
   
   ## How was this patch tested?
   
   Unit Tests
   
   This PR was assisted by Cursor.


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