Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-13121

NPE when request file descriptors when SC read

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.0.0
    • 3.2.0, 3.1.1, 3.0.4
    • hdfs-client
    • None

    Description

      Recently, we hit an issue that the DFSClient throws NPE. The case is that, the app process exceeds the limit of the max open file. In the case, the libhadoop never throw and exception but return null to the request of fds. But requestFileDescriptors use the returned fds directly without any check and then NPE. 

       

      We need add a sanity check here of null pointer.

       

      private ShortCircuitReplicaInfo requestFileDescriptors(DomainPeer peer,
      Slot slot) throws IOException {
      ShortCircuitCache cache = clientContext.getShortCircuitCache();
      final DataOutputStream out =
      new DataOutputStream(new BufferedOutputStream(peer.getOutputStream()));
      SlotId slotId = slot == null ? null : slot.getSlotId();
      new Sender(out).requestShortCircuitFds(block, token, slotId, 1,
      failureInjector.getSupportsReceiptVerification());
      DataInputStream in = new DataInputStream(peer.getInputStream());
      BlockOpResponseProto resp = BlockOpResponseProto.parseFrom(
      PBHelperClient.vintPrefixed(in));
      DomainSocket sock = peer.getDomainSocket();
      failureInjector.injectRequestFileDescriptorsFailure();
      switch (resp.getStatus()) {
      case SUCCESS:
      byte buf[] = new byte[1];
      FileInputStream[] fis = new FileInputStream[2];
      sock.recvFileInputStreams(fis, buf, 0, buf.length);
      ShortCircuitReplica replica = null;
      try {
      ExtendedBlockId key =
      new ExtendedBlockId(block.getBlockId(), block.getBlockPoolId());
      if (buf[0] == USE_RECEIPT_VERIFICATION.getNumber()) {
      LOG.trace("Sending receipt verification byte for slot {}", slot);
      sock.getOutputStream().write(0);
      }
      replica = new ShortCircuitReplica(key, fis[0], fis[1], cache,
      Time.monotonicNow(), slot);

      Attachments

        1. HDFS-13121.04.patch
          7 kB
          Zsolt Venczel
        2. HDFS-13121.03.patch
          7 kB
          Zsolt Venczel
        3. test-only.patch
          6 kB
          Zsolt Venczel
        4. HDFS-13121.02.patch
          6 kB
          Zsolt Venczel
        5. HDFS-13121.01.patch
          1 kB
          Zsolt Venczel

        Activity

          People

            zvenczel Zsolt Venczel
            xiegang112 Gang Xie
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: