You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2020/01/23 22:59:36 UTC

[GitHub] [hadoop-ozone] hanishakoneru commented on a change in pull request #448: HDDS-2870. Handle replay of KeyCreate requests.

hanishakoneru commented on a change in pull request #448: HDDS-2870. Handle replay of KeyCreate requests.
URL: https://github.com/apache/hadoop-ozone/pull/448#discussion_r370399963
 
 

 ##########
 File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyCreateRequest.java
 ##########
 @@ -174,26 +182,40 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager,
       // bucket encryptionInfo will be not set. If this assumption holds
       // true, we can avoid get from bucket table.
 
+      // Check if Key already exists
+      String dbKeyName = omMetadataManager.getOzoneKey(volumeName, bucketName,
+          keyName);
+      OmKeyInfo dbKeyInfo = omMetadataManager.getKeyTable().get(dbKeyName);
+      if (dbKeyInfo != null) {
+        // Check if this transaction is a replay of ratis logs.
+        if (isReplay(ozoneManager, dbKeyInfo.getUpdateID(),
+            transactionLogIndex)) {
+          // Replay implies the response has already been returned to
+          // the client. So take no further action and return a dummy
+          // OMClientResponse.
+          LOG.debug("Replayed Transaction {} ignored. Request: {}",
+              transactionLogIndex, createKeyRequest);
+          return new OMKeyCreateResponse(createReplayOMResponse(omResponse));
+        }
+      }
+
       OmBucketInfo bucketInfo = omMetadataManager.getBucketTable().get(
               omMetadataManager.getBucketKey(volumeName, bucketName));
 
       encryptionInfo = getFileEncryptionInfo(ozoneManager, bucketInfo);
 
-      omKeyInfo = prepareKeyInfo(omMetadataManager, keyArgs,
-          omMetadataManager.getOzoneKey(volumeName, bucketName, keyName),
+      omKeyInfo = prepareKeyInfo(omMetadataManager, keyArgs, dbKeyName,
           keyArgs.getDataSize(), locations, encryptionInfo.orNull(),
           ozoneManager.getPrefixManager(), bucketInfo, transactionLogIndex);
-      omClientResponse = prepareCreateKeyResponse(keyArgs, omKeyInfo,
-          locations, encryptionInfo.orNull(), exception,
+      omClientResponse = prepareCreateKeyResponse(omResponse, keyArgs,
 
 Review comment:
   Done.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-issues-help@hadoop.apache.org