swamirishi commented on code in PR #9131:
URL: https://github.com/apache/ozone/pull/9131#discussion_r2483812877


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMDbCheckpointServletInodeBasedXfer.java:
##########
@@ -586,6 +599,176 @@ public void testBootstrapLockBlocksMultipleServices() 
throws Exception {
     assertTrue(servicesSucceeded.get() > 0, "Services should have succeeded 
after lock release");
   }
 
+  /**
+   * Tests the full checkpoint servlet flow to ensure snapshot paths are read
+   * from checkpoint metadata (frozen state) rather than live OM metadata 
(current state).
+   * Scenario:
+   * 1. Create snapshots S1, S2, S3
+   * 2. Purge S2
+   * 3. Checkpoint is created
+   * 4. S3 gets purged from live OM (after checkpoint creation)
+   * 5. Servlet processes checkpoint - should still include S1, S3 data as
+   *    checkpoint snapshotInfoTable has S1 S3
+   */
+  @Test
+  public void testCheckpointIncludesSnapshotsFromFrozenState() throws 
Exception {
+    String volumeName = "vol" + RandomStringUtils.secure().nextNumeric(5);
+    String bucketName = "buck" + RandomStringUtils.secure().nextNumeric(5);
+
+    setupCluster();
+    om.getKeyManager().getSnapshotSstFilteringService().pause();
+
+    // Create test data and snapshots
+    OzoneBucket bucket = TestDataUtil.createVolumeAndBucket(client, 
volumeName, bucketName);
+
+    // Create key before first snapshot
+    TestDataUtil.createKey(bucket, "key1",
+        ReplicationConfig.fromTypeAndFactor(ReplicationType.RATIS, 
ReplicationFactor.ONE),
+        "data1".getBytes(StandardCharsets.UTF_8));
+    client.getObjectStore().createSnapshot(volumeName, bucketName, 
"snapshot1");
+    client.getObjectStore().createSnapshot(volumeName, bucketName, 
"snapshot2");
+
+    // At this point: Live OM has snapshots S1, S2
+    List<OzoneSnapshot> snapshots = new ArrayList<>();
+    client.getObjectStore().listSnapshot(volumeName, bucketName, "", null)
+        .forEachRemaining(snapshots::add);
+    assertEquals(2, snapshots.size(), "Should have 2 snapshots initially");
+    OzoneSnapshot snapshot2 = snapshots.stream()
+        .filter(snap -> snap.getName().equals("snapshot2"))
+        .findFirst()
+        .orElseThrow(() -> new RuntimeException("snapshot2 not found"));
+
+    purgeSnapshot(volumeName, bucketName, snapshot2);
+
+    // Setup servlet mocks for checkpoint processing
+    setupMocks();
+    
when(requestMock.getParameter(OZONE_DB_CHECKPOINT_INCLUDE_SNAPSHOT_DATA)).thenReturn("true");
+    // custom lock because the original lock waits for double buffer flush.
+    BootstrapStateHandler.Lock customLock = new BootstrapStateHandler.Lock() {
+      private final List<BootstrapStateHandler.Lock> serviceLocks;

Review Comment:
   If that is the case I don't think purge snapshot race condition is even 
possible. Then we should just deal with the create snapshot race condition



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