Details
-
Sub-task
-
Status: Resolved
-
Major
-
Resolution: Invalid
-
None
-
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.