HBASE-21795 Client application may get stuck (time bound) if a table modify op is called immediately after split op

Signed-off-by: zhangduo <zhangduo@apache.org>
This commit is contained in:
Nihal Jain 2019-01-28 14:05:25 +05:30 committed by zhangduo
parent d69c3e5d48
commit 5f8bdd52a1
2 changed files with 64 additions and 1 deletions

View File

@ -1412,7 +1412,9 @@ public class AssignmentManager {
final List<RegionState> states = regionStates.getTableRegionStates(tableName);
int ritCount = 0;
for (RegionState regionState: states) {
if (!regionState.isOpened()) ritCount++;
if (!regionState.isOpened() && !regionState.isSplit()) {
ritCount++;
}
}
return new Pair<Integer, Integer>(ritCount, states.size());
}

View File

@ -46,6 +46,7 @@ import org.apache.hadoop.hbase.TableNotDisabledException;
import org.apache.hadoop.hbase.TableNotEnabledException;
import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.UnknownRegionException;
import org.apache.hadoop.hbase.Waiter.Predicate;
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
import org.apache.hadoop.hbase.constraint.ConstraintException;
import org.apache.hadoop.hbase.ipc.HBaseRpcController;
@ -793,4 +794,64 @@ public class TestAdmin2 {
Assert.assertEquals(expectedStoreFilesSize, store.getSize());
}
}
@Test
public void testTableSplitFollowedByModify() throws Exception {
final TableName tableName = TableName.valueOf(name.getMethodName());
TEST_UTIL.createTable(tableName, Bytes.toBytes("f"));
// get the original table region count
List<RegionInfo> regions = admin.getRegions(tableName);
int originalCount = regions.size();
assertEquals(1, originalCount);
// split the table and wait until region count increases
admin.split(tableName, Bytes.toBytes(3));
TEST_UTIL.waitFor(30000, new Predicate<Exception>() {
@Override
public boolean evaluate() throws Exception {
return admin.getRegions(tableName).size() > originalCount;
}
});
// do some table modification
TableDescriptor tableDesc = TableDescriptorBuilder.newBuilder(admin.getDescriptor(tableName))
.setMaxFileSize(11111111)
.build();
admin.modifyTable(tableDesc);
assertEquals(11111111, admin.getDescriptor(tableName).getMaxFileSize());
}
@Test
public void testTableMergeFollowedByModify() throws Exception {
final TableName tableName = TableName.valueOf(name.getMethodName());
TEST_UTIL.createTable(tableName, new byte[][] { Bytes.toBytes("f") },
new byte[][] { Bytes.toBytes(3) });
// assert we have at least 2 regions in the table
List<RegionInfo> regions = admin.getRegions(tableName);
int originalCount = regions.size();
assertTrue(originalCount >= 2);
byte[] nameOfRegionA = regions.get(0).getEncodedNameAsBytes();
byte[] nameOfRegionB = regions.get(1).getEncodedNameAsBytes();
// merge the table regions and wait until region count decreases
admin.mergeRegionsAsync(nameOfRegionA, nameOfRegionB, true);
TEST_UTIL.waitFor(30000, new Predicate<Exception>() {
@Override
public boolean evaluate() throws Exception {
return admin.getRegions(tableName).size() < originalCount;
}
});
// do some table modification
TableDescriptor tableDesc = TableDescriptorBuilder.newBuilder(admin.getDescriptor(tableName))
.setMaxFileSize(11111111)
.build();
admin.modifyTable(tableDesc);
assertEquals(11111111, admin.getDescriptor(tableName).getMaxFileSize());
}
}