-
Notifications
You must be signed in to change notification settings - Fork 587
HDDS-9312. Expand all the entries deletedDirTable for Snapshot. #5339
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
Conversation
|
cc: @swamirishi |
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/SnapshotInfo.java
Show resolved
Hide resolved
| snapshotInfoActual.getExclusiveSize()); | ||
| Assert.assertEquals(snapshotInfoExpected.getExclusiveReplicatedSize(), | ||
| snapshotInfoActual.getExclusiveReplicatedSize()); | ||
| Assert.assertEquals(snapshotInfoExpected.getExpandedDeletedDir(), |
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.
Can we just assertEquals on snapshotInfoExpected and snapshotInfoActual?
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.
Yes we can, but this is just to check each field individually.
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.
assertEquals() will do the same thing as long as equals method is overridden.
https://github.com/junit-team/junit4/blob/main/src/main/java/org/junit/Assert.java#L145
...ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/DirectoryDeletingService.java
Outdated
Show resolved
Hide resolved
...ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/DirectoryDeletingService.java
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| Table.KeyValue<String, OmKeyInfo> deletedDirInfo; | ||
| List<Pair<String, OmKeyInfo>> allSubDirList |
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.
nit: Is there any specific reason it is list of Pair? If no, use map instead for simplification.
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.
This is also a copy-pasta from the DirectoryDeletingService. This was the structure used by the service all this time. So I kept it this way.
| List<Pair<String, OmKeyInfo>> allSubDirList | ||
| = new ArrayList<>((int) remainNum); | ||
|
|
||
| try (TableIterator<String, ? extends Table.KeyValue<String, |
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.
Code inside this try block is mostly duplicate of above try block. Duplication can be removed, if you create a helper function and extract this out. It will also improve the readability.
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.
We can't fully extract it because we use some snapshot-specific code in-between. So I kept it separately.
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.
https://github.com/apache/ozone/blob/master/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/DirectoryDeletingService.java#L180-L216 and https://github.com/apache/ozone/pull/5339/files#diff-7ec30412dac9f4304cc72760eec9efe605e901ec3a7d379551da7c6ab67ea7eaR294-R331 exactly same except pendingDeletedDirInfo changed to deletedDirInfo which I think is just variable name change. I believe you can extract you the table entry processing.
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.
One more point, we are not iterating over deletedIterator? Is it intentional? Also do we need to call deletedIterator.seekToFirst(); and deletedIterator.hasNext(); before calling deletedIterator.next(); ?
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.
Correct I missed that part with copy-pasting, I have updated the PR.
| if (remainNum > 0) { | ||
| expandSnapshotDirectories(remainNum); | ||
| } | ||
| } catch (Exception e) { |
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 think you can just catch this exception inside expandSnapshotDirectories and log there instead of logging it here.
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.
expandSnapshotDirectories already has its own separate logging for something similar.
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.
Then it is double logging. May be expandSnapshotDirectories doesn't need to throw an IOException.
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.
It will throw because we still do get from RocksDB. But the exception on inside of expandSnapshotDirectories is specific for iterating through snapDeletedDirTable. The one outside is overall exeption. The main reason is expandSnapshotDirectories already las many try blocks, adding more will decrease the readability.
swamirishi
left a comment
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.
@aswinshakil thanks for the patch. Have a few review comments from the first round of review. I will add more comments as and when I get more clarity on the whole thing.
|
|
||
| // Expand deleted dirs only on active snapshot. Deleted Snapshots | ||
| // will be cleaned up by SnapshotDeletingService. | ||
| if (currSnapInfo.getSnapshotStatus() != SNAPSHOT_ACTIVE || |
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.
We should take a lock on this snapshot to avoid race condition
| "null for snapshotted bucket. The OM is in unexpected state."); | ||
| } | ||
|
|
||
| String dbBucketKeyForDir = getOzoneManager().getMetadataManager() |
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.
Can we have some kind of a util function for this? or use one if it is already there. As in appending OM_KEY_PREFIX at the end.
| currSnapInfo.getVolumeName(), | ||
| currSnapInfo.getBucketName(), | ||
| getSnapshotPrefix(currSnapInfo.getName()), | ||
| true)) { |
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 guess this should be false here. skipActiveCheck has to be false.
| subFileNum += request.getDeletedSubFilesCount(); | ||
| } | ||
|
|
||
| optimizeDirDeletesAndSubmitRequest( |
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.
From what I understand this would put a request to expand the directory and manipulate the directory table and key table entries. I am not sure how this would impact snapshot diff. @hemantk-12 @prashantpogde .
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.
Full diff and Dag based diff will start showing different outputs.
|
We have discussed a different approach to not modify |
What changes were proposed in this pull request?
Currently, deleted directories are kept in snapshot's
deletedDirTable. It doesn't have information on the total size of the keys it holds. So we won't be able to get theexclusiveSizeof the snapshot unless we expand it. This PR expands thedeledDirTableof all the snapshots.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-9312
How was this patch tested?
Added Integration Test.