HBASE-16527 IOExceptions from DFS client still can cause CatalogJanitor to delete referenced files (Vladimir Rodionov)

This commit is contained in:
tedyu 2016-09-01 12:39:08 -07:00
parent d91edc2ac4
commit a034a2bdcb
2 changed files with 25 additions and 16 deletions

View File

@ -404,26 +404,26 @@ public class CatalogJanitor extends ScheduledChore {
return new Pair<Boolean, Boolean>(Boolean.FALSE, Boolean.FALSE);
}
} catch (IOException ioe) {
LOG.warn("Error trying to determine if daughter region exists, " +
LOG.error("Error trying to determine if daughter region exists, " +
"assuming exists and has references", ioe);
return new Pair<Boolean, Boolean>(Boolean.TRUE, Boolean.TRUE);
}
try {
regionFs = HRegionFileSystem.openRegionFromFileSystem(
this.services.getConfiguration(), fs, tabledir, daughter, true);
} catch (IOException e) {
LOG.warn("Error trying to determine referenced files from : " + daughter.getEncodedName()
+ ", to: " + parent.getEncodedName() + " assuming has references", e);
return new Pair<Boolean, Boolean>(Boolean.TRUE, Boolean.TRUE);
}
boolean references = false;
HTableDescriptor parentDescriptor = getTableDescriptor(parent.getTable());
for (HColumnDescriptor family: parentDescriptor.getFamilies()) {
if ((references = regionFs.hasReferences(family.getNameAsString()))) {
break;
try {
regionFs = HRegionFileSystem.openRegionFromFileSystem(
this.services.getConfiguration(), fs, tabledir, daughter, true);
for (HColumnDescriptor family: parentDescriptor.getFamilies()) {
if ((references = regionFs.hasReferences(family.getNameAsString()))) {
break;
}
}
} catch (IOException e) {
LOG.error("Error trying to determine referenced files from : " + daughter.getEncodedName()
+ ", to: " + parent.getEncodedName() + " assuming has references", e);
return new Pair<Boolean, Boolean>(Boolean.TRUE, Boolean.TRUE);
}
return new Pair<Boolean, Boolean>(Boolean.TRUE, Boolean.valueOf(references));
}

View File

@ -251,9 +251,18 @@ public class HRegionFileSystem {
* @throws IOException
*/
public boolean hasReferences(final String familyName) throws IOException {
FileStatus[] files = FSUtils.listStatus(fs, getStoreDir(familyName),
new FSUtils.ReferenceFileFilter(fs));
return files != null && files.length > 0;
FileStatus[] files = FSUtils.listStatus(fs, getStoreDir(familyName));
if (files != null) {
for(FileStatus stat: files) {
if(stat.isDirectory()) {
continue;
}
if(StoreFileInfo.isReference(stat.getPath())) {
return true;
}
}
}
return false;
}
/**