hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ji...@apache.org
Subject [11/50] hadoop git commit: HADOOP-12484. Single File Rename Throws Incorrectly In Potential Race Condition Scenarios. Contributed by Gaurav Kanade.
Date Tue, 27 Oct 2015 21:47:22 GMT
HADOOP-12484. Single File Rename Throws Incorrectly In Potential Race Condition Scenarios.
Contributed by Gaurav Kanade.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/cb282d5b
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/cb282d5b
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/cb282d5b

Branch: refs/heads/HDFS-8966
Commit: cb282d5b89fdece4719cc4ad37a6e27f13371534
Parents: 0fce5f9
Author: cnauroth <cnauroth@apache.org>
Authored: Thu Oct 22 14:29:57 2015 -0700
Committer: cnauroth <cnauroth@apache.org>
Committed: Thu Oct 22 14:29:57 2015 -0700

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt |  3 ++
 .../hadoop/fs/azure/NativeAzureFileSystem.java  | 32 +++++++++++++++++---
 2 files changed, 30 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/cb282d5b/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 74c62cb..87ba2ba 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -1338,6 +1338,9 @@ Release 2.8.0 - UNRELEASED
     HADOOP-12334. Change Mode Of Copy Operation of HBase WAL Archiving to bypass
     Azure Storage Throttling after retries. (Gaurav Kanade via cnauroth)
 
+    HADOOP-12484. Single File Rename Throws Incorrectly In Potential Race
+    Condition Scenarios. (Gaurav Kanade via cnauroth)
+
 Release 2.7.2 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/cb282d5b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/NativeAzureFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/NativeAzureFileSystem.java
b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/NativeAzureFileSystem.java
index b963d5a1..9305b24 100644
--- a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/NativeAzureFileSystem.java
+++ b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/NativeAzureFileSystem.java
@@ -545,10 +545,32 @@ public class NativeAzureFileSystem extends FileSystem {
 
         // Get a lease on source to block write access.
         String srcName = fs.pathToKey(srcFile);
-        SelfRenewingLease lease = fs.acquireLease(srcFile);
-
-        // Delete the file. This will free the lease too.
-        fs.getStoreInterface().delete(srcName, lease);
+        SelfRenewingLease lease = null;
+        try {
+          lease = fs.acquireLease(srcFile);
+          // Delete the file. This will free the lease too.
+          fs.getStoreInterface().delete(srcName, lease);
+        } catch(AzureException e) {
+            String errorCode = "";
+            try {
+              StorageException e2 = (StorageException) e.getCause();
+              errorCode = e2.getErrorCode();
+            } catch(Exception e3) {
+              // do nothing if cast fails
+            }
+            // If the rename already finished do nothing
+            if(!errorCode.equals("BlobNotFound")){
+              throw e;
+            }
+        } finally {
+          try {
+            if(lease != null){
+              lease.free();
+            }
+          } catch(StorageException e) {
+            LOG.warn("Unable to free lease because: " + e.getMessage());
+          }
+        }
       } else if (!srcExists && dstExists) {
 
         // The rename already finished, so do nothing.
@@ -2442,4 +2464,4 @@ public class NativeAzureFileSystem extends FileSystem {
       }
     }
   }
-}
\ No newline at end of file
+}


Mime
View raw message