smengcl commented on code in PR #9810:
URL: https://github.com/apache/ozone/pull/9810#discussion_r3635308018


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java:
##########
@@ -284,12 +284,23 @@ public OmSnapshotManager(OzoneManager ozoneManager) 
throws IOException {
 
   public static boolean isSnapshotPurged(SnapshotChainManager chainManager, 
OMMetadataManager omMetadataManager,
       UUID snapshotId, TransactionInfo transactionInfo) throws IOException {
+    boolean purgeFlushed = transactionInfo != null &&
+        isTransactionFlushedToDisk(omMetadataManager, transactionInfo);
     String tableKey = chainManager.getTableKey(snapshotId);
     if (tableKey == null) {
-      return true;
+      // Snapshot chain is rebuilt from DB on every OM restart 
(loadFromSnapshotInfoTable),
+      // but entries committed to the Raft log (but not yet flushed) after the 
restart
+      // are applied in addToDBBatch (skipping validateAndUpdateCache), so 
they never call
+      // addSnapshot(). This can affect any OM (leader or follower) after a 
restart.

Review Comment:
   A better code comment would be:
   
   ```suggestion
         // A null tableKey only means the in-memory chain has no entry for 
this snapshotId. It does
         // not by itself mean the snapshot was purged.
         //
         // snapshotIdToTableKey is discarded and rebuilt from the DB 
(loadFromSnapshotInfoTable)
         // every time a SnapshotChainManager is constructed, which happens on 
OM startup and again
         // on a follower when installCheckpoint() swaps in a leader checkpoint 
and restarts the
         // metadata manager. A snapshot that is still live in the DB can be 
missing from the
         // rebuilt index, so treating a null tableKey as "purged" would report 
a live snapshot as
         // gone -- the orphan-version mishandling in HDDS-14699.
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to