smengcl commented on code in PR #5167:
URL: https://github.com/apache/ozone/pull/5167#discussion_r1289544817
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestHSync.java:
##########
@@ -131,6 +146,47 @@ public static void teardown() {
}
}
+ @Test
+ public void testKeyHSyncThenClose() throws IOException {
+ // Check that deletedTable should not have keys with the same block as in
+ // keyTable's when a key is hsync()'ed then close()'d.
+
+ // 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 String dir = OZONE_ROOT + bucket.getVolumeName()
+ + OZONE_URI_DELIMITER + bucket.getName();
+
+ String data = "random data";
+ final Path file = new Path(dir, "file-hsync-then-close");
+ try (FileSystem fs = FileSystem.get(CONF)) {
+ try (FSDataOutputStream outputStream = fs.create(file, true)) {
+ outputStream.write(data.getBytes(UTF_8), 0, data.length());
+ outputStream.hsync();
+ }
+ }
+
+ OMMetadataManager ommm = cluster.getOzoneManager().getMetadataManager();
+ // deletedTable should not have an entry for file at all in this case
+ try (TableIterator<String,
+ ? extends Table.KeyValue<String, RepeatedOmKeyInfo>>
+ tableIter = ommm.getDeletedTable().iterator()) {
+ while (tableIter.hasNext()) {
+ Table.KeyValue<String, RepeatedOmKeyInfo> kv = tableIter.next();
+ String key = kv.getKey();
+ if (key.startsWith(file.toString())) {
Review Comment:
> Also key string will not match file string anyway
It works. Try commenting out this line, run the test and see it fail:
https://github.com/apache/ozone/blob/edad661120a6b7e4490754323ed241423447a96e/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyCommitRequestWithFSO.java#L216
--
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]