Index: src/main/java/org/apache/hadoop/hbase/regionserver/Store.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/regionserver/Store.java (revision 1431004) +++ src/main/java/org/apache/hadoop/hbase/regionserver/Store.java (working copy) @@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.regionserver; import java.io.IOException; +import java.io.InterruptedIOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -412,26 +413,38 @@ totalValidStoreFile++; } + IOException ioe = null; try { for (int i = 0; i < totalValidStoreFile; i++) { - Future future = completionService.take(); - StoreFile storeFile = future.get(); - long length = storeFile.getReader().length(); - this.storeSize += length; - this.totalUncompressedBytes += - storeFile.getReader().getTotalUncompressedBytes(); - if (LOG.isDebugEnabled()) { - LOG.debug("loaded " + storeFile.toStringDetailed()); - } - results.add(storeFile); - } - } catch (InterruptedException e) { - throw new IOException(e); - } catch (ExecutionException e) { - throw new IOException(e.getCause()); + try { + Future future = completionService.take(); + StoreFile storeFile = future.get(); + long length = storeFile.getReader().length(); + this.storeSize += length; + this.totalUncompressedBytes += + storeFile.getReader().getTotalUncompressedBytes(); + if (LOG.isDebugEnabled()) { + LOG.debug("loaded " + storeFile.toStringDetailed()); + } + results.add(storeFile); + } catch (InterruptedException e) { + if (ioe == null) ioe = new InterruptedIOException(e.getMessage()); + } catch (ExecutionException e) { + if (ioe == null) ioe = new IOException(e.getCause()); + } + } } finally { storeFileOpenerThreadPool.shutdownNow(); } + if (ioe != null) { + // close StoreFile readers + try { + for (StoreFile file : results) { + if (file != null) file.closeReader(true); + } + } catch (IOException e) { } + throw ioe; + } return results; } @@ -651,18 +664,25 @@ }); } + IOException ioe = null; try { for (int i = 0; i < result.size(); i++) { - Future future = completionService.take(); - future.get(); + try { + Future future = completionService.take(); + future.get(); + } catch (InterruptedException e) { + if (ioe == null) { + ioe = new InterruptedIOException(); + ioe.initCause(e); + } + } catch (ExecutionException e) { + if (ioe == null) ioe = new IOException(e.getCause()); + } } - } catch (InterruptedException e) { - throw new IOException(e); - } catch (ExecutionException e) { - throw new IOException(e.getCause()); } finally { storeFileCloserThreadPool.shutdownNow(); } + if (ioe != null) throw ioe; } LOG.info("Closed " + this); return result; Index: src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java (revision 1431004) +++ src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java (working copy) @@ -599,7 +599,16 @@ */ public Reader createReader() throws IOException { if (this.reader == null) { - this.reader = open(); + try { + this.reader = open(); + } catch (IOException e) { + try { + this.closeReader(true); + } catch (IOException ee) { + } + throw e; + } + } return this.reader; }