HBASE-10193 - Cleanup HRegion if one of the store fails to open at region initialization (Aditya Kishore)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1552716 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
ramkrishna 2013-12-20 16:16:54 +00:00
parent edb5f7c0ae
commit 28c3e3a61c
2 changed files with 18 additions and 3 deletions

View File

@ -692,6 +692,7 @@ public class HRegion implements HeapSize { // , Writable{
}
});
}
boolean allStoresOpened = false;
try {
for (int i = 0; i < htableDescriptor.getFamilies().size(); i++) {
Future<HStore> future = completionService.take();
@ -712,12 +713,24 @@ public class HRegion implements HeapSize { // , Writable{
maxMemstoreTS = maxStoreMemstoreTS;
}
}
allStoresOpened = true;
} catch (InterruptedException e) {
throw new IOException(e);
} catch (ExecutionException e) {
throw new IOException(e.getCause());
} finally {
storeOpenerThreadPool.shutdownNow();
if (!allStoresOpened) {
// something went wrong, close all opened stores
LOG.error("Could not initialize all stores for the region=" + this);
for (Store store : this.stores.values()) {
try {
store.close();
} catch (IOException e) {
LOG.warn(e.getMessage());
}
}
}
}
}
mvcc.initialize(maxMemstoreTS + 1);

View File

@ -524,11 +524,13 @@ public class HStore implements Store {
}
if (ioe != null) {
// close StoreFile readers
try {
for (StoreFile file : results) {
for (StoreFile file : results) {
try {
if (file != null) file.closeReader(true);
} catch (IOException e) {
LOG.warn(e.getMessage());
}
} catch (IOException e) { }
}
throw ioe;
}