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


##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestKeyDeletingService.java:
##########
@@ -849,6 +850,91 @@ void testSnapshotExclusiveSize() throws Exception {
     }
   }
 
+  @Nested
+  @TestInstance(TestInstance.Lifecycle.PER_CLASS)
+  class SnapshotDbHandleLifecycle {
+
+    @BeforeAll
+    void setup(@TempDir File testDir) throws Exception {
+      scmBlockTestingClient = new ScmBlockLocationTestingClient(null, null, 0);
+      createConfig(testDir);
+      createSubject();
+      keyDeletingService.shutdown();
+    }
+
+    @AfterAll
+    void cleanup() {
+      if (om.stop()) {
+        om.join();
+      }
+    }
+
+    @Test
+    @DisplayName("KeyDeletingService should close the snapshot DB handle 
before submitting an OM request")
+    void testSnapshotDbHandleClosedBeforeSubmit() throws Exception {
+      String volumeName = getTestName();
+      String bucketName = uniqueObjectName("bucket");
+      String snapshotName = uniqueObjectName("snap");
+      createVolumeAndBucket(volumeName, bucketName, false);
+      writeClient.createSnapshot(volumeName, bucketName, snapshotName);
+      om.awaitDoubleBufferFlush();
+
+      String snapshotKey = SnapshotInfo.getTableKey(volumeName, bucketName, 
snapshotName);
+      SnapshotInfo snapshotInfo = 
metadataManager.getSnapshotInfoTable().get(snapshotKey);
+      GenericTestUtils.waitFor(() -> {
+        try {
+          return 
OmSnapshotManager.areSnapshotChangesFlushedToDB(metadataManager, snapshotInfo);
+        } catch (IOException e) {
+          throw new UncheckedIOException(e);
+        }
+      }, 100, 10000);
+      snapshotInfo.setDeepCleanedDeletedDir(true);

Review Comment:
   Good catch. The test now persists the updated SnapshotInfo with 
snapshotInfoTable.put(...) before constructing the task, matching the existing 
snapshot integration-test setup and removing the dependency on mutable 
table-cache object identity. Verified the isolated regression (1/1), the full 
TestKeyDeletingService suite (18/18), and all 58 Checkstyle modules. Fixed in 
d502a5eea60.



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