Skip to content
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

HDDS-3930. Fix OMKeyDeletesRequest. #1169

Closed
wants to merge 29 commits into from
Closed

HDDS-3930. Fix OMKeyDeletesRequest. #1169

wants to merge 29 commits into from

Conversation

bharatviswa504
Copy link
Contributor

What changes were proposed in this pull request?

  1. The cache of the key should be updated in ValidateAndUpdateCache, as we return response once after adding to cache, and before DoubleBuffer flushes to disk using OmClientResponse#addToDBBatch.
  2. Changed return type of DeleteKeysResponse, as anyway when success we are not returning delete list and also when failure, we fail complete batch. So we can just return status.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-3930

How was this patch tested?

Existing tests.

Copy link
Contributor

@smengcl smengcl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bharatviswa504 for the PR. I have some comments.

@codecov-commenter
Copy link

codecov-commenter commented Jul 9, 2020

Codecov Report

Merging #1169 into master will increase coverage by 0.08%.
The diff coverage is 94.23%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1169      +/-   ##
============================================
+ Coverage     73.50%   73.59%   +0.08%     
- Complexity    10037    10137     +100     
============================================
  Files           974      974              
  Lines         49685    50086     +401     
  Branches       4883     4979      +96     
============================================
+ Hits          36523    36862     +339     
- Misses        10845    10889      +44     
- Partials       2317     2335      +18     
Impacted Files Coverage Δ Complexity Δ
...pache/hadoop/ozone/om/request/OMClientRequest.java 86.56% <ø> (-0.78%) 26.00 <0.00> (-3.00)
...doop/ozone/om/request/key/OMKeysDeleteRequest.java 94.56% <92.10%> (+7.35%) 10.00 <0.00> (+1.00)
...n/java/org/apache/hadoop/ozone/audit/OMAction.java 100.00% <100.00%> (ø) 2.00 <0.00> (ø)
...op/ozone/om/response/key/OMKeysDeleteResponse.java 100.00% <100.00%> (+20.51%) 4.00 <2.00> (+1.00)
...doop/ozone/om/exceptions/OMNotLeaderException.java 48.48% <0.00%> (-18.19%) 3.00% <0.00%> (-2.00%)
...e/container/keyvalue/impl/ChunkManagerFactory.java 70.00% <0.00%> (-8.58%) 4.00% <0.00%> (ø%)
...p/ozone/security/OzoneDelegationTokenSelector.java 72.22% <0.00%> (-5.56%) 7.00% <0.00%> (-1.00%)
...PB/OzoneManagerProtocolServerSideTranslatorPB.java 82.92% <0.00%> (-2.44%) 17.00% <0.00%> (-1.00%)
...iner/ozoneimpl/ContainerScrubberConfiguration.java 80.00% <0.00%> (-1.82%) 8.00% <0.00%> (+1.00%) ⬇️
...doop/ozone/container/keyvalue/KeyValueHandler.java 63.55% <0.00%> (-1.56%) 66.00% <0.00%> (-1.00%)
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a84d5bc...62eded8. Read the comment docs.

Copy link
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bharatviswa504 for updating the patch. Audit now looks good. There are a few places where I think more change is needed.

}
}
public void deleteKeys(OmDeleteKeys deleteKeys) throws IOException {
throw new NotImplementedException("OzoneManager does not require this to " +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider changing to UnsupportedOperationException as

NotImplementedException represents the case where the author has yet to implement the logic at this point in the program

Comment on lines 173 to 174
for (int i = indexFailed; i < length; i++) {
unDeletedKeys.addKeys(deleteKeyArgs.getKeys(indexFailed));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not repeatedly add the same key:

Suggested change
for (int i = indexFailed; i < length; i++) {
unDeletedKeys.addKeys(deleteKeyArgs.getKeys(indexFailed));
for (int i = indexFailed; i < length; i++) {
unDeletedKeys.addKeys(deleteKeyArgs.getKeys(i));


auditLog(auditLogger, buildAuditMessage(
OMAction.DELETE_KEYS, auditMap, exception, userInfo));


switch (result) {
case SUCCESS:
omMetrics.decNumKeys();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should decrease number of keys by deleteKeys.size().

Comment on lines 200 to 201
LOG.debug("Key deleted. Volume:{}, Bucket:{}, Key:{}", volumeName,
bucketName, keyName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to log all keys:

Suggested change
LOG.debug("Key deleted. Volume:{}, Bucket:{}, Key:{}", volumeName,
bucketName, keyName);
LOG.debug("Key deleted. Volume:{}, Bucket:{}, Key:{}", volumeName,
bucketName, deleteKeys);


auditLog(auditLogger, buildAuditMessage(
OMAction.DELETE_KEYS, auditMap, exception, userInfo));


switch (result) {
case SUCCESS:
omMetrics.decNumKeys();
LOG.debug("Key deleted. Volume:{}, Bucket:{}, Key:{}", volumeName,
bucketName, keyName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the success case, the omMetrics.decNumKeys() only -1, which does not reflect the deleted keys if there are more than one key in the request.

NIT: in success case, we only put the keyName of the last successful delete. If we want to put the names of all deleted keys. We should guard it with if (LOG.isDebugEnabled())

case FAILURE:
omMetrics.incNumKeyDeleteFails();
LOG.error("Key delete failed. Volume:{}, Bucket:{}, Key{}." +
" Exception:{}", volumeName, bucketName, keyName, exception);
LOG.error("Key delete failed. Volume:{}, Bucket:{}, Key:{}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we reword the error message to differentiate with the single delete.

LOG.error("Key delete failed. Volume:{}, Bucket:{}, Key{}." +
" Exception:{}", volumeName, bucketName, keyName, exception);
LOG.error("Key delete failed. Volume:{}, Bucket:{}, Key:{}",
volumeName, bucketName, keyName, exception);
break;
default:
LOG.error("Unrecognized Result for OMKeyDeleteRequest: {}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OMKeyDeleteRequest=> OMKeysDeleteRequest

Copy link
Contributor

@xiaoyuyao xiaoyuyao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bharatviswa504 for the update. Just few minor comments, otherwise LGTM.

@bharatviswa504
Copy link
Contributor Author

Thank You @xiaoyuyao and @adoroszlai for the review.
Addressed review comments.

@sonarcloud
Copy link

sonarcloud bot commented Jul 10, 2020

SonarCloud Quality Gate failed.

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 4 Code Smells

77.4% 77.4% Coverage
0.0% 0.0% Duplication

warning The version of Java (1.8.0_232) you have used to run this analysis is deprecated and we will stop accepting it from October 2020. Please update to at least Java 11.
Read more here

@bharatviswa504 bharatviswa504 deleted the HDDS-3930 branch July 10, 2020 22:38
@bharatviswa504 bharatviswa504 restored the HDDS-3930 branch July 10, 2020 22:39
@bharatviswa504
Copy link
Contributor Author

This is being closed and opened as #1195
As the branch for this accidentally created in apache repo.

@bharatviswa504 bharatviswa504 deleted the HDDS-3930 branch July 10, 2020 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants