You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2013/01/09 21:33:45 UTC
svn commit: r1431046 - in
/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver:
Store.java StoreFile.java
Author: tedyu
Date: Wed Jan 9 20:33:45 2013
New Revision: 1431046
URL: http://svn.apache.org/viewvc?rev=1431046&view=rev
Log:
HBASE-7515 Store.loadStoreFiles should close opened files if there's an exception (Ted Yu)
Modified:
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java?rev=1431046&r1=1431045&r2=1431046&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java Wed Jan 9 20:33:45 2013
@@ -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 @@ public class Store extends SchemaConfigu
totalValidStoreFile++;
}
+ IOException ioe = null;
try {
for (int i = 0; i < totalValidStoreFile; i++) {
- Future<StoreFile> 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<StoreFile> 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 @@ public class Store extends SchemaConfigu
});
}
+ IOException ioe = null;
try {
for (int i = 0; i < result.size(); i++) {
- Future<Void> future = completionService.take();
- future.get();
+ try {
+ Future<Void> 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;
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java?rev=1431046&r1=1431045&r2=1431046&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java Wed Jan 9 20:33:45 2013
@@ -599,7 +599,16 @@ public class StoreFile extends SchemaCon
*/
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;
}