You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "kaijchen (via GitHub)" <gi...@apache.org> on 2023/02/03 14:14:51 UTC
[GitHub] [ozone] kaijchen commented on a diff in pull request #4236: HDDS-7871. Fix false positive in KeyManagerImpl#createFakeDirIfShould()
kaijchen commented on code in PR #4236:
URL: https://github.com/apache/ozone/pull/4236#discussion_r1095845345
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestKeyManagerImpl.java:
##########
@@ -1351,6 +1353,51 @@ public void testGetFileStatusWithFakeDir() throws IOException {
Assert.assertTrue(ozoneFileStatus.isFile());
}
+ @Test
+ public void testGetFileStatusWithFakeDirForHDDS7871() throws IOException {
+ String dirName = "foo2";
+ String fileName = "bar2";
+ String keyName1 = "foo1";
+ // keyName2 = "foo2/bar2"
+ String keyName2 = dirName + OZONE_URI_DELIMITER + fileName;
+ OzoneFileStatus ozoneFileStatus;
+
+ // create a key "foo1" in bucket1
+ OmKeyArgs keyArgs = createBuilder(BUCKET_NAME).setKeyName(keyName1).build();
+ OpenKeySession keySession = writeClient.openKey(keyArgs);
+ keyArgs.setLocationInfoList(
+ keySession.getKeyInfo().getLatestVersionLocations().getLocationList());
+ writeClient.commitKey(keyArgs, keySession.getId());
+
+ // create a key "foo2/bar2" in bucket2
+ keyArgs = createBuilder(BUCKET2_NAME).setKeyName(keyName2).build();
+ keySession = writeClient.createFile(keyArgs, true, true);
+ keyArgs.setLocationInfoList(
+ keySession.getKeyInfo().getLatestVersionLocations().getLocationList());
+ writeClient.commitKey(keyArgs, keySession.getId());
+
+ // Verify the following dbKeys in key table:
+ // 1. "volume1/bucket1/foo1"
+ // 2. "volume1/bucket2/foo2/bar2"
+ Assert.assertNotNull(metadataManager.getKeyTable(getDefaultBucketLayout())
+ .get(metadataManager.getOzoneKey(VOLUME_NAME, BUCKET_NAME, keyName1)));
+ Assert.assertNotNull(metadataManager.getKeyTable(getDefaultBucketLayout())
+ .get(metadataManager.getOzoneKey(VOLUME_NAME, BUCKET2_NAME, keyName2)));
+
+ // get a non-existing "foo2" from bucket1, RocksIter#seek() will find the
+ // 2nd dbKey "volume1/bucket2/foo2/bar2", which is not belong to bucket1.
Review Comment:
> `RocksIterator#seek()` may position at the key **past the target**
Yes, here seeking `volume1/bucket1/foo2/`, it will position at `volume1/bucket2/foo2/bar2`.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org