bharatviswa504 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_r367761604
########## 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: We can pass the dbKeyInfo to prepareKeyInfo, as for override keys we read from DB. As anyway to check whether it is replay or not we read from DB above we can use that. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org