ashishkumar50 commented on code in PR #7551:
URL: https://github.com/apache/ozone/pull/7551#discussion_r1877747558


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestHSync.java:
##########
@@ -496,6 +496,54 @@ public void testOfsHSync(boolean incrementalChunkList) 
throws Exception {
     }
   }
 
+  @Test
+  public void testHSyncOpenKeyCommitAfterExpiry() throws Exception {
+    // Set the fs.defaultFS
+    final String rootPath = String.format("%s://%s/",
+        OZONE_OFS_URI_SCHEME, CONF.get(OZONE_OM_ADDRESS_KEY));
+    CONF.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, rootPath);
+
+    final Path key1 = new Path("hsync-key");
+    final Path key2 = new Path("hsync-key1");
+
+    try (FileSystem fs = FileSystem.get(CONF)) {
+      // Create key1
+      try (FSDataOutputStream os = fs.create(key1, true)) {
+        os.write(1);
+        os.hsync();
+        // Create key2
+        try (FSDataOutputStream os1 = fs.create(key2, true)) {
+          os1.write(1);
+          os1.hsync();
+          // There should be 2 key in openFileTable
+          assertThat(2 == getOpenKeyInfo(BUCKET_LAYOUT).size());
+          assertThat(2 == getKeyInfo(BUCKET_LAYOUT).size());
+
+          // Resume openKeyCleanupService
+          openKeyCleanupService.resume();
+          GenericTestUtils.waitFor(() -> 0 == 
getOpenKeyInfo(BUCKET_LAYOUT).size(), 1000, 12000);
+
+          // Verify entry from openKey gets committed eventually
+          GenericTestUtils.waitFor(() ->
+              0 == getOpenKeyInfo(BUCKET_LAYOUT).size(), 1000, 12000);
+          // Verify key is still present
+          assertThat(2 == getKeyInfo(BUCKET_LAYOUT).size());
+
+          // Clean up
+          assertTrue(fs.delete(key1, false));
+          assertTrue(fs.delete(key2, false));
+          waitForEmptyDeletedTable();
+        } catch (OMException ex) {
+          assertEquals(OMException.ResultCodes.KEY_NOT_FOUND, ex.getResult());

Review Comment:
   Added one hsync and one normal key.
   
   > if key2 is not explicitly deleted, will os1 still throws KEY_NOT_FOUND?
   
   Yes because when os1 is geting closed it will try to commit key and which it 
will not find and throws KEY_NOT_FOUND error.



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