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-2870. Handle replay of KeyCreate requests. #448

Merged
merged 3 commits into from Jan 28, 2020

Conversation

hanishakoneru
Copy link
Contributor

@hanishakoneru hanishakoneru commented Jan 16, 2020

What changes were proposed in this pull request?

To ensure that key creation operation is idempotent, compare the transactionID with the objectID and updateID to make sure that the transaction is not a replay. If the transactionID <= updateID, then it implies that the transaction is a replay and hence it should be skipped.

OMKeyCreateRequest and OMFileCreateRequest are made idempotent in this Jira.

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

How was this patch tested?

Unit tests to verify replayed transactions return expected response.

@hanishakoneru
Copy link
Contributor Author

Thank you @bharatviswa504 for the review. I addressed them in the new commit.

omAction.getAction(), keyName, bucketName, volumeName, exception);
omClientResponse = createKeyErrorResponse(ozoneManager.getMetrics(),
omAction, exception, omResponse);
// Append blocks
Copy link
Contributor

Choose a reason for hiding this comment

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

We are adding blocks twice for the case when keyInfo != null, as once in prepareKeyInfo and here again.
So, can we move the creation of KeyInfo logic to prepareKeyInfo and use prepareCreateKeyResponse just to generate OmClientResponse.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we are adding blocks only once. But still, if we consolidate the logic it will be good. Okay with doing that in a new Jira also.

Copy link
Contributor

@bharatviswa504 bharatviswa504 left a comment

Choose a reason for hiding this comment

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

Thank You @hanishakoneru for the update.
Few comments, once they are addressed it is good to go.

HDDS-2870. Unit tests

HDDS-2870. checkstyle fixes

HDDS-2870. Unit test for FileCreateRequest

review comments

Refactored OMKeyRequest#prepareKeyInfo and OMKeyRequest#prepareCreateKeyResponse

checkstyle
OmKeyInfo dbKeyInfo = omMetadataManager.getKeyTable().get(ozoneKey);
if (dbKeyInfo != null) {
// Check if this transaction is a replay of ratis logs.
// Check if this transaction is a replay of ratis logs.
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: Duplicate // Check if this transaction is a replay of ratis logs.
We can remove one.

keyArgs.getDataSize(), locations, encryptionInfo.orNull(),
ozoneManager.getPrefixManager(), bucketInfo, trxnLogIndex);

long openVersion = omKeyInfo.getLatestVersionLocations().getVersion();
Copy link
Contributor

Choose a reason for hiding this comment

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

L302-L318 is common for FileCreate and KeyCreate can we move into a method and use it.
Or we can move these to prepareKeyInfo from 302-310 and add new method to add to cache and response. In this way OmKeyInfo will be generated by prepareKeyInfo and response and adding to cache will be in a new method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue is we have to get the openVersion before appending new blocks. Hence, I kept these lines out of prepareKeyInfo.
I can add the appendBlocks and updateCache calls to another method. But since it was just 2 calls, i though it could be outside.

Copy link
Contributor

Choose a reason for hiding this comment

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

@hanishakoneru We shall open a new Jira to address this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When i move the append blocks code inside prepareKeyInfo, it breaks multiplartUpload. TestOzoneSecure#testMultipartUploadOverride() fails because of this. This was done as part of HDDS-2944.
So going to keep append blocks outside the prepareKeyInfo() function.

}

public OMFileCreateResponse(@Nonnull OMResponse omResponse) {
super(omResponse);
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: Missing checkStatusNotOK() and also can we add similar javadoc as OMKeyCreateResponse.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this. If you are ok with rest of the patch, I add this check in the next Jira HDDS-2944.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure.

Copy link
Contributor

@bharatviswa504 bharatviswa504 left a comment

Choose a reason for hiding this comment

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

Thank You @hanishakoneru for the update.
I have a few comments, rest LGTM.

@bharatviswa504 bharatviswa504 merged commit 66abf65 into apache:master Jan 28, 2020
@bharatviswa504
Copy link
Contributor

Thank You @hanishakoneru for the contribution.

@hanishakoneru
Copy link
Contributor Author

Thank you @bharatviswa504 . I have addressed the two pending comments in HDDS-2944.

@hanishakoneru hanishakoneru deleted the HDDS-2870 branch December 1, 2020 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants