Wei-Chiu Chuang created HDDS-4471:
-------------------------------------

             Summary: GrpcOutputStream length can overflow
                 Key: HDDS-4471
                 URL: https://issues.apache.org/jira/browse/HDDS-4471
             Project: Hadoop Distributed Data Store
          Issue Type: Bug
          Components: Ozone Datanode
    Affects Versions: 1.0.0
            Reporter: Wei-Chiu Chuang


DN says it sent negative bytes of container data to destination.

{noformat}
2020-11-16 22:07:26,445 INFO 
org.apache.hadoop.ozone.container.replication.GrpcReplicationService: Streaming 
container data (982134) to other datanode
2020-11-16 22:16:37,693 INFO 
org.apache.hadoop.ozone.container.replication.GrpcOutputStream: Sent 
-2033242913 bytes for container 982134
{noformat}

Looks like there was an overflow. The writtenBytes shouldn't be an int, because 
the container is as big as 5GB, easily overflow a signed int.

{code:title=GrpcOutputStream.java}
  private int writtenBytes;

...
      CopyContainerResponseProto response =
          CopyContainerResponseProto.newBuilder()
              .setContainerID(containerId)
              .setData(data)
              .setEof(eof)
              .setReadOffset(writtenBytes)
              .setLen(length)
              .build();
      responseObserver.onNext(response);
      writtenBytes += length;
{code}

Looking at the source code, I think we can change it to long without breaking 
serialization compatibility because setReadOffset() expects a long.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org
For additional commands, e-mail: issues-h...@ozone.apache.org

Reply via email to