This is an automated email from the ASF dual-hosted git repository.

sammichen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 18f1461  HDDS-6203. CleanUp incomplete gz files during Container move 
(#3000)
18f1461 is described below

commit 18f1461b2832d60835ca3a99a43ac6a5c9992ed1
Author: Nibiru <[email protected]>
AuthorDate: Sun Jan 23 10:27:25 2022 +0800

    HDDS-6203. CleanUp incomplete gz files during Container move (#3000)
---
 .../container/replication/GrpcReplicationClient.java      | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git 
a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/GrpcReplicationClient.java
 
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/GrpcReplicationClient.java
index 548d114..91c7400 100644
--- 
a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/GrpcReplicationClient.java
+++ 
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/GrpcReplicationClient.java
@@ -161,7 +161,16 @@ public class GrpcReplicationClient implements 
AutoCloseable{
       try {
         chunk.getData().writeTo(stream);
       } catch (IOException e) {
-        response.completeExceptionally(e);
+        LOG.error("Failed to write the stream buffer to {} for container {}",
+            outputPath, containerId, e);
+        try {
+          stream.close();
+        } catch (IOException ex) {
+          LOG.error("Failed to close OutputStream {}", outputPath, e);
+        } finally {
+          deleteOutputOnFailure();
+          response.completeExceptionally(e);
+        }
       }
     }
 
@@ -176,6 +185,7 @@ public class GrpcReplicationClient implements AutoCloseable{
       } catch (IOException e) {
         LOG.error("Failed to close {} for container {}",
             outputPath, containerId, e);
+        deleteOutputOnFailure();
         response.completeExceptionally(e);
       }
     }
@@ -189,9 +199,9 @@ public class GrpcReplicationClient implements AutoCloseable{
       } catch (IOException e) {
         LOG.error("Downloaded container {} OK, but failed to close {}",
             containerId, outputPath, e);
+        deleteOutputOnFailure();
         response.completeExceptionally(e);
       }
-
     }
 
     private void deleteOutputOnFailure() {
@@ -204,5 +214,4 @@ public class GrpcReplicationClient implements AutoCloseable{
       }
     }
   }
-
 }

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

Reply via email to