szetszwo commented on code in PR #884:
URL: https://github.com/apache/ratis/pull/884#discussion_r1221293654


##########
ratis-netty/src/main/java/org/apache/ratis/netty/server/DataStreamManagement.java:
##########
@@ -96,6 +96,10 @@ CompletableFuture<Long> write(ByteBuf buf, 
Iterable<WriteOption> options,
           n -> streamFuture.thenCompose(stream -> writeToAsync(buf, options, 
stream, executor)
               .whenComplete((l, e) -> metrics.stop(context, e == null))));
     }
+
+    void cleanUp() {
+      streamFuture.thenAccept(DataStream::cleanUp);
+    }

Review Comment:
   When there is an IOE, it should still close the file as below.
   ```java
   +++ 
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/KeyValueStreamDataChannel.java
   @@ -198,8 +198,11 @@ void assertOpen() throws IOException {
      @Override
      public void close() throws IOException {
        if (closed.compareAndSet(false, true)) {
   -      putBlockRequest.set(closeBuffers(buffers, super::writeFileChannel));
   -      super.close();
   +      try {
   +        putBlockRequest.set(closeBuffers(buffers, super::writeFileChannel));
   +      } finally {
   +        super.close();
   +      }
        }
      }
   ```
   Also, it probably should also delete the file
   ```java
   +++ 
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/LocalStream.java
   @@ -46,6 +46,7 @@ public CompletableFuture<?> cleanUp() {
            dataChannel.close();
            return true;
          } catch (IOException e) {
   +        // TODO delete the file?
            throw new CompletionException("Failed to close data channel", e);
          }
        });
   ```



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to