Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-8031 Follow-on work for erasure coding phase I (striping layout)
  3. HDFS-9832

Erasure Coding: Improve exception handling in ErasureCodingWorker#ReconstructAndTransferBlock

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • None
    • 3.0.0-alpha1
    • erasure-coding
    • None

    Description

      There are three places in ErasureCodingWorker#ReconstructAndTransferBlock that I think can be improved.
      1.In run method, the step3 transfer data will be failed sometimes, and this will cause buffers not be cleared completely, is better to invoke clearBuffer again in finally handling?

              while (positionInBlock < maxTargetLength) {
                final int toReconstruct = (int) Math.min(
                    bufferSize, maxTargetLength - positionInBlock);
                // step1: read from minimum source DNs required for reconstruction.
                // The returned success list is the source DNs we do real read from
                Map<ExtendedBlock, Set<DatanodeInfo>> corruptionMap = new HashMap<>();
                try {
                  success = readMinimumStripedData4Reconstruction(success,
                      toReconstruct, corruptionMap);
                } finally {
                  // report corrupted blocks to NN
                  reportCorruptedBlocks(corruptionMap);
                }
      
                // step2: decode to reconstruct targets
                reconstructTargets(success, targetsStatus, toReconstruct);
      
                // step3: transfer data
                if (transferData2Targets(targetsStatus) == 0) {
                  String error = "Transfer failed for all targets.";
                  throw new IOException(error);
                }
      
                clearBuffers();
                positionInBlock += toReconstruct;
              }
      

      2.Is better to set null to buffers objects, targetsOutput and socket objects in finally handling code?

            } finally {
              datanode.decrementXmitsInProgress();
              // close block readers
              for (StripedReader stripedReader : stripedReaders) {
                closeBlockReader(stripedReader.blockReader);
              }
              for (int i = 0; i < targets.length; i++) {
                IOUtils.closeStream(targetOutputStreams[i]);
                IOUtils.closeStream(targetInputStreams[i]);
                IOUtils.closeStream(targetSockets[i]);
              }
            }
      

      3.buffers in ReconstructAndTransferBlock are not released. In clearBuffers, it will finally invoke buffer.clear(), but this only change the index position and not really release the space. So this seems not a small problem.

      Attachments

        1. HDFS-9832.001.patch
          2 kB
          Yiqun Lin

        Activity

          People

            linyiqun Yiqun Lin
            linyiqun Yiqun Lin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: