-
Notifications
You must be signed in to change notification settings - Fork 593
HDDS-10220. Add test case to cover HDDS-9930 batch key deletion #7792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
peterxcli
wants to merge
2
commits into
apache:master
from
peterxcli:hdds10220-add-tests-for-hdds-9930-batch-key-delete
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok sorry now I recall what we wanted to cover in this test case.
We want to open the files, write, hsync; while it's still open, delete the keys.
The try with resources pattern closes the file after exiting this block, so that's not what we want.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jojochuang Thanks for the reminder.
I update the test to not use
try with resources pattern, and it failed to receive the exception from the second hsync operation after the keys are deleted. I'm still investigating whether the root cause is my incorrect test or an issue in #6472There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds like a product bug to me. Potentially something inside OmKeysDeleteRequestWithFSO.
Note: we have two separate request types for handling single delete and batch deletes. So mistakes can happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some logs to the existing
testHsync#testHSyncDeletedKeyand found the following:It appears that the key
/-9223372036854775552/-9223372036854775040/-9223372036854775040/key-hsync-del/113980087550083073was written during the first hsync process:ozone/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/response/key/OMKeyCommitResponseWithFSO.java
Lines 83 to 84 in 0ba9147
Given this, I believe we should modify the approach to pass the complete key name along with the desired open key/file info metadata.
I’d love to hear your thoughts on this. I really appreciate your input, @jojochuang.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I added a fail(...) to test if the exception really happened
@Test public void testHSyncDeletedKey() throws Exception { // Verify that a key can't be successfully hsync'ed again after it's deleted, // and that key won't reappear after a failed hsync. // 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(); final Path key1 = new Path(dir, "key-hsync-del"); try (FileSystem fs = FileSystem.get(CONF)) { // Create key1 try (FSDataOutputStream os = fs.create(key1, true)) { os.write(1); os.hsync(); fs.delete(key1, false); // getFileStatus should throw FNFE because the key is deleted assertThrows(FileNotFoundException.class, () -> fs.getFileStatus(key1)); // hsync should throw because the open key is gone try { os.hsync(); + fail("hsync should throw because the open key is gone"); } catch (OMException omEx) { assertEquals(OMException.ResultCodes.KEY_NOT_FOUND, omEx.getResult()); } // key1 should not reappear after failed hsync assertThrows(FileNotFoundException.class, () -> fs.getFileStatus(key1)); } catch (OMException ex) { // os.close() throws OMException because the key is deleted assertEquals(OMException.ResultCodes.KEY_NOT_FOUND, ex.getResult()); } } }then it failed with: