HBASE-18743 HFiles in use by a table which has the same name and namespace with a default table cloned from snapshot may be deleted when that snapshot and default table are deleted (wenbang)

This commit is contained in:
tedyu 2017-09-04 07:52:57 -07:00
parent 8ce811c6ed
commit d5033fd350
3 changed files with 16 additions and 3 deletions

View File

@ -388,7 +388,7 @@ public final class TableName implements Comparable<TableName> {
for (TableName tn : tableCache) { for (TableName tn : tableCache) {
if (qualifierAsString.equals(tn.getQualifierAsString()) && if (qualifierAsString.equals(tn.getQualifierAsString()) &&
namespaceAsString.equals(tn.getNameAsString())) { namespaceAsString.equals(tn.getNamespaceAsString())) {
return tn; return tn;
} }
} }

View File

@ -393,4 +393,16 @@ public class TestNamespace {
fail("Should have thrown exception " + exceptionClass); fail("Should have thrown exception " + exceptionClass);
} }
@Test
public void testValueOfNamespaceAndQualifier() {
TableName name0 = TableName.valueOf("table");
TableName name1 = TableName.valueOf("table", "table");
assertEquals(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR, name0.getNamespaceAsString());
assertEquals("table", name0.getQualifierAsString());
assertEquals("table", name0.getNameAsString());
assertEquals("table", name1.getNamespaceAsString());
assertEquals("table", name1.getQualifierAsString());
assertEquals("table:table", name1.getNameAsString());
}
} }

View File

@ -102,7 +102,8 @@ public class TestHFileLink {
TableName.NAMESPACE_DELIM, '=') + "=" + encodedRegion + "-" + storeFileName; TableName.NAMESPACE_DELIM, '=') + "=" + encodedRegion + "-" + storeFileName;
TableName tableNames[] = {TableName.valueOf("tableName1"), TableName tableNames[] = {TableName.valueOf("tableName1"),
TableName.valueOf("ns", "tableName2")}; TableName.valueOf("ns", "tableName2"),
TableName.valueOf("refTable:refTable")};
for( TableName tableName : tableNames) { for( TableName tableName : tableNames) {
Path tableDir = FSUtils.getTableDir(rootDir, tableName); Path tableDir = FSUtils.getTableDir(rootDir, tableName);
@ -112,7 +113,7 @@ public class TestHFileLink {
//Verify back reference creation //Verify back reference creation
assertEquals(encodedRegion+"."+ assertEquals(encodedRegion+"."+
tableName.getNameAsString().replace(TableName.NAMESPACE_DELIM, '='), tableName.getNameAsString().replace(TableName.NAMESPACE_DELIM, '='),
HFileLink.createBackReferenceName(tableName.getNameAsString(), HFileLink.createBackReferenceName(FSUtils.getTableName(tableDir).getNameAsString(),
encodedRegion)); encodedRegion));
//verify parsing back reference //verify parsing back reference