HBASE-21644 Modify table procedure runs infinitely for a table having region replication > 1
Signed-off-by: zhangduo <zhangduo@apache.org>
This commit is contained in:
parent
331a7f2bda
commit
70fb6951d8
|
@ -999,7 +999,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
|||
// Use maximum of log sequenceid or that which was found in stores
|
||||
// (particularly if no recovered edits, seqid will be -1).
|
||||
long maxSeqIdFromFile =
|
||||
WALSplitter.getMaxRegionSequenceId(getWalFileSystem(), getWALRegionDir());
|
||||
WALSplitter.getMaxRegionSequenceId(getWalFileSystem(), getWALRegionDirOfDefaultReplica());
|
||||
long nextSeqId = Math.max(maxSeqId, maxSeqIdFromFile) + 1;
|
||||
// The openSeqNum will always be increase even for read only region, as we rely on it to
|
||||
// determine whether a region has been successfully reopend, so here we always need to update
|
||||
|
@ -1931,6 +1931,19 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
|||
return regionDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Region directory under WALRootDirectory; in case of secondary replica return the
|
||||
* region directory corresponding to its default replica
|
||||
* @throws IOException if there is an error getting WALRootDir
|
||||
*/
|
||||
private Path getWALRegionDirOfDefaultReplica() throws IOException {
|
||||
RegionInfo regionInfo = getRegionInfo();
|
||||
if (!RegionReplicaUtil.isDefaultReplica(regionInfo)) {
|
||||
regionInfo = RegionReplicaUtil.getRegionInfoForDefaultReplica(regionInfo);
|
||||
}
|
||||
return FSUtils.getWALRegionDir(conf, regionInfo.getTable(), regionInfo.getEncodedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEarliestFlushTimeForAllStores() {
|
||||
return Collections.min(lastStoreFlushTimeMap.values());
|
||||
|
|
|
@ -1555,4 +1555,24 @@ public class TestAdmin1 {
|
|||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifyTableOnTableWithRegionReplicas() throws Exception {
|
||||
TableName tableName = TableName.valueOf(name.getMethodName());
|
||||
TableDescriptor desc = TableDescriptorBuilder.newBuilder(tableName)
|
||||
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(Bytes.toBytes("cf")))
|
||||
.setRegionReplication(5)
|
||||
.build();
|
||||
|
||||
admin.createTable(desc);
|
||||
|
||||
int maxFileSize = 10000000;
|
||||
TableDescriptor newDesc = TableDescriptorBuilder.newBuilder(desc)
|
||||
.setMaxFileSize(maxFileSize)
|
||||
.build();
|
||||
|
||||
admin.modifyTable(newDesc);
|
||||
TableDescriptor newTableDesc = admin.getDescriptor(tableName);
|
||||
assertEquals(maxFileSize, newTableDesc.getMaxFileSize());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,8 +33,12 @@ import org.apache.hadoop.hbase.HTableDescriptor;
|
|||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.TableNotFoundException;
|
||||
import org.apache.hadoop.hbase.client.Admin;
|
||||
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
|
||||
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
|
||||
import org.apache.hadoop.hbase.client.Connection;
|
||||
import org.apache.hadoop.hbase.client.ConnectionFactory;
|
||||
import org.apache.hadoop.hbase.client.TableDescriptor;
|
||||
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
|
||||
import org.apache.hadoop.hbase.replication.BaseReplicationEndpoint;
|
||||
import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
|
||||
import org.apache.hadoop.hbase.replication.TestReplicationBase;
|
||||
|
@ -178,6 +182,28 @@ public class TestReplicationAdminWithClusters extends TestReplicationBase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnableReplicationForTableWithRegionReplica() throws Exception {
|
||||
TableName tn = TableName.valueOf(name.getMethodName());
|
||||
TableDescriptor td = TableDescriptorBuilder.newBuilder(tn)
|
||||
.setRegionReplication(5)
|
||||
.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(noRepfamName).build())
|
||||
.build();
|
||||
|
||||
admin1.createTable(td);
|
||||
|
||||
try {
|
||||
admin1.enableTableReplication(tn);
|
||||
td = admin1.getDescriptor(tn);
|
||||
for (ColumnFamilyDescriptor fam : td.getColumnFamilies()) {
|
||||
assertEquals(HConstants.REPLICATION_SCOPE_GLOBAL, fam.getScope());
|
||||
}
|
||||
} finally {
|
||||
utility1.deleteTable(tn);
|
||||
utility2.deleteTable(tn);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = TableNotFoundException.class)
|
||||
public void testDisableReplicationForNonExistingTable() throws Exception {
|
||||
admin1.disableTableReplication(TableName.valueOf(name.getMethodName()));
|
||||
|
|
Loading…
Reference in New Issue