You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2020/12/10 14:26:27 UTC
[hbase] branch branch-2.3 updated: HBASE-25287 Forgetting to
unbuffer streams results in many CLOSE_WAIT sockets when loading files
(#2699)
This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch branch-2.3
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.3 by this push:
new 2a5250a HBASE-25287 Forgetting to unbuffer streams results in many CLOSE_WAIT sockets when loading files (#2699)
2a5250a is described below
commit 2a5250a21e8dd22724a16de165deeef51c0bc811
Author: haxl <li...@gmail.com>
AuthorDate: Thu Dec 10 22:15:39 2020 +0800
HBASE-25287 Forgetting to unbuffer streams results in many CLOSE_WAIT sockets when loading files (#2699)
Signed-off-by: Andrew Purtell <ap...@apache.org>
Signed-off-by: Duo Zhang <zh...@apache.org>
---
.../apache/hadoop/hbase/io/hfile/HFileInfo.java | 52 +++++++++++++---------
1 file changed, 30 insertions(+), 22 deletions(-)
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileInfo.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileInfo.java
index ad469c0..0751a24 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileInfo.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileInfo.java
@@ -340,8 +340,8 @@ public class HFileInfo implements SortedMap<byte[], byte[]> {
Path path = context.getFilePath();
checkFileVersion(path);
this.hfileContext = createHFileContext(path, trailer, conf);
- } catch (Throwable t) {
context.getInputStreamWrapper().unbuffer();
+ } catch (Throwable t) {
IOUtils.closeQuietly(context.getInputStreamWrapper());
throw new CorruptHFileException("Problem reading HFile Trailer from file "
+ context.getFilePath(), t);
@@ -353,28 +353,36 @@ public class HFileInfo implements SortedMap<byte[], byte[]> {
*/
public void initMetaAndIndex(HFile.Reader reader) throws IOException {
ReaderContext context = reader.getContext();
- HFileBlock.FSReader blockReader = reader.getUncachedBlockReader();
- // Initialize an block iterator, and parse load-on-open blocks in the following.
- blockIter = blockReader.blockRange(trailer.getLoadOnOpenDataOffset(),
- context.getFileSize() - trailer.getTrailerSize());
- // Data index. We also read statistics about the block index written after
- // the root level.
- this.dataIndexReader = new HFileBlockIndex
- .CellBasedKeyBlockIndexReader(trailer.createComparator(), trailer.getNumDataIndexLevels());
- dataIndexReader.readMultiLevelIndexRoot(blockIter.nextBlockWithBlockType(BlockType.ROOT_INDEX),
- trailer.getDataIndexCount());
- reader.setDataBlockIndexReader(dataIndexReader);
- // Meta index.
- this.metaIndexReader = new HFileBlockIndex.ByteArrayKeyBlockIndexReader(1);
- metaIndexReader.readRootIndex(blockIter.nextBlockWithBlockType(BlockType.ROOT_INDEX),
+ try {
+ HFileBlock.FSReader blockReader = reader.getUncachedBlockReader();
+ // Initialize an block iterator, and parse load-on-open blocks in the following.
+ blockIter = blockReader.blockRange(trailer.getLoadOnOpenDataOffset(),
+ context.getFileSize() - trailer.getTrailerSize());
+ // Data index. We also read statistics about the block index written after
+ // the root level.
+ this.dataIndexReader =
+ new HFileBlockIndex.CellBasedKeyBlockIndexReader(trailer.createComparator(), trailer.getNumDataIndexLevels());
+ dataIndexReader
+ .readMultiLevelIndexRoot(blockIter.nextBlockWithBlockType(BlockType.ROOT_INDEX), trailer.getDataIndexCount());
+ reader.setDataBlockIndexReader(dataIndexReader);
+ // Meta index.
+ this.metaIndexReader = new HFileBlockIndex.ByteArrayKeyBlockIndexReader(1);
+ metaIndexReader.readRootIndex(blockIter.nextBlockWithBlockType(BlockType.ROOT_INDEX),
trailer.getMetaIndexCount());
- reader.setMetaBlockIndexReader(metaIndexReader);
- loadMetaInfo(blockIter, hfileContext);
- reader.setDataBlockEncoder(HFileDataBlockEncoderImpl.createFromFileInfo(this));
- // Load-On-Open info
- HFileBlock b;
- while ((b = blockIter.nextBlock()) != null) {
- loadOnOpenBlocks.add(b);
+ reader.setMetaBlockIndexReader(metaIndexReader);
+ loadMetaInfo(blockIter, hfileContext);
+ reader.setDataBlockEncoder(HFileDataBlockEncoderImpl.createFromFileInfo(this));
+ // Load-On-Open info
+ HFileBlock b;
+ while ((b = blockIter.nextBlock()) != null) {
+ loadOnOpenBlocks.add(b);
+ }
+ // close the block reader
+ context.getInputStreamWrapper().unbuffer();
+ } catch (Throwable t) {
+ IOUtils.closeQuietly(context.getInputStreamWrapper());
+ throw new CorruptHFileException("Problem reading data index and meta index from file "
+ + context.getFilePath(), t);
}
}