swamirishi commented on code in PR #9131:
URL: https://github.com/apache/ozone/pull/9131#discussion_r2481514499
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMDbCheckpointServletInodeBasedXfer.java:
##########
@@ -586,6 +592,119 @@ 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
+ * 2. Create Snapshot S3
+ * 3. Checkpoint is created (freezes state with S1, S2)
+ * 4. S2 gets purged from live OM (after checkpoint creation)
+ * 5. Servlet processes checkpoint - should still include S2 data
+ */
+ @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");
+
+ // Create key before second snapshot
+ TestDataUtil.createKey(bucket, "key2",
+ ReplicationConfig.fromTypeAndFactor(ReplicationType.RATIS,
ReplicationFactor.ONE),
+ "data2".getBytes(StandardCharsets.UTF_8));
+ client.getObjectStore().createSnapshot(volumeName, bucketName,
"snapshot2");
+ TestDataUtil.createKey(bucket, "key3",
+ ReplicationConfig.fromTypeAndFactor(ReplicationType.RATIS,
ReplicationFactor.ONE),
+ "data3".getBytes(StandardCharsets.UTF_8));
+ client.getObjectStore().createSnapshot(volumeName, bucketName,
"snapshot3");
+ om.getMetadataManager().getStore().flushDB();
+
+ // At this point: Live OM has snapshots S1, S2
+ List<OzoneSnapshot> snapshotsBeforePurge = new ArrayList<>();
+ client.getObjectStore().listSnapshot(volumeName, bucketName, "", null)
+ .forEachRemaining(snapshotsBeforePurge::add);
+ assertEquals(3, snapshotsBeforePurge.size(), "Should have 3 snapshots
initially");
+ OzoneSnapshot snapshot2 = snapshotsBeforePurge.stream()
+ .filter(snap -> snap.getName().equals("snapshot2"))
+ .findFirst()
+ .orElseThrow(() -> new RuntimeException("snapshot2 not found"));
+ OzoneSnapshot snapshot3 = snapshotsBeforePurge.stream()
+ .filter(snap -> snap.getName().equals("snapshot3"))
+ .findFirst()
+ .orElseThrow(() -> new RuntimeException("snapshot2 not found"));
+
+ // Setup servlet mocks for checkpoint processing
+ setupMocks();
+
when(requestMock.getParameter(OZONE_DB_CHECKPOINT_INCLUDE_SNAPSHOT_DATA)).thenReturn("true");
+
+ // Create a checkpoint that captures current state (S1, S2)
+ DBStore dbStore = om.getMetadataManager().getStore();
+ DBStore spyDbStore = spy(dbStore);
+ AtomicReference<DBCheckpoint> capturedCheckpoint = new AtomicReference<>();
+
+ when(spyDbStore.getCheckpoint(true)).thenAnswer(invocation -> {
+ DBCheckpoint checkpoint = spy(dbStore.getCheckpoint(true));
+ doNothing().when(checkpoint).cleanupCheckpoint(); // Don't cleanup for
verification
+ capturedCheckpoint.set(checkpoint);
+ return checkpoint;
+ });
Review Comment:
Can we do the bootstrap on the follower OM? Bootstrap lock there won't mean
anything when this runs on the follower. To get into this condition maybe we
should mock bootstrap lock to do a noop here.
Actually what we should do is during BootstrapLock we should pause the
double buffer thread delete the snapshot and acquire the bootstrap lock. Now
just before the checkpoint we should unpause the double buffer thread and let
the snapshot purge get flushed this would do it.
--
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]