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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to