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/31 02:46:15 UTC

[GitHub] [hadoop-ozone] bharatviswa504 commented on a change in pull request #505: HDDS-2956. Handle Replay of AllocateBlock request

bharatviswa504 commented on a change in pull request #505: HDDS-2956. Handle Replay of AllocateBlock request
URL: https://github.com/apache/hadoop-ozone/pull/505#discussion_r373294644
 
 

 ##########
 File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMAllocateBlockRequest.java
 ##########
 @@ -160,71 +160,98 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager,
     Map<String, String> auditMap = buildKeyArgsAuditMap(keyArgs);
     auditMap.put(OzoneConsts.CLIENT_ID, String.valueOf(clientID));
 
+    OMMetadataManager omMetadataManager = ozoneManager.getMetadataManager();
+    String openKeyName = omMetadataManager.getOpenKey(volumeName, bucketName,
+        keyName, clientID);
+
     OMResponse.Builder omResponse = OMResponse.newBuilder().setCmdType(
         OzoneManagerProtocolProtos.Type.AllocateBlock).setStatus(
         OzoneManagerProtocolProtos.Status.OK).setSuccess(true);
+    OMClientResponse omClientResponse = null;
 
+    OmKeyInfo openKeyInfo = null;
     IOException exception = null;
-    OmKeyInfo omKeyInfo = null;
+
     try {
       // check Acl
       checkKeyAclsInOpenKeyTable(ozoneManager, volumeName, bucketName, keyName,
           IAccessAuthorizer.ACLType.WRITE, allocateBlockRequest.getClientID());
 
-      OMMetadataManager omMetadataManager = ozoneManager.getMetadataManager();
       validateBucketAndVolume(omMetadataManager, volumeName,
           bucketName);
 
-      String openKey = omMetadataManager.getOpenKey(
-          volumeName, bucketName, keyName, clientID);
-
       // Here we don't acquire bucket/volume lock because for a single client
       // allocateBlock is called in serial fashion.
 
-      omKeyInfo = omMetadataManager.getOpenKeyTable().get(openKey);
-      if (omKeyInfo == null) {
-        throw new OMException("Open Key not found " + openKey, KEY_NOT_FOUND);
+      openKeyInfo = omMetadataManager.getOpenKeyTable().get(openKeyName);
+      if (openKeyInfo == null) {
+        // Check if this transaction is a replay of ratis logs.
+        // If the Key was already committed and this transaction is being
+        // replayed, we should ignore this transaction.
+        String ozoneKey = omMetadataManager.getOzoneKey(volumeName,
 
 Review comment:
   I think, this check will help only when Key is created and Committed. But it will not help in the scenario:
   T1 - Key Create
   T2 - allocate block
   T3 - Key Commit
   T4- Key Delete
   When replay, we will still throw an error, as it will not be in the openKeyTable. So, I think it is okay not to get from key table and do a check. As we cannot 100% find replay transactions.

----------------------------------------------------------------
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