HBASE-4815 Disable online altering by default, create a config for it

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1203916 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2011-11-19 00:26:59 +00:00
parent cc7e469310
commit c42e7e1028
4 changed files with 54 additions and 3 deletions

View File

@ -437,6 +437,7 @@ Release 0.92.0 - Unreleased
HBASE-4796 Race between SplitRegionHandlers for the same region kills the master HBASE-4796 Race between SplitRegionHandlers for the same region kills the master
HBASE-4816 Regionserver wouldn't go down because split happened exactly at same HBASE-4816 Regionserver wouldn't go down because split happened exactly at same
time we issued bulk user region close call on our way out time we issued bulk user region close call on our way out
HBASE-4815 Disable online altering by default, create a config for it
TESTS TESTS
HBASE-4450 test for number of blocks read: to serve as baseline for expected HBASE-4450 test for number of blocks read: to serve as baseline for expected

View File

@ -69,7 +69,8 @@ public abstract class TableEventHandler extends EventHandler {
try { try {
this.masterServices.checkTableModifiable(tableName); this.masterServices.checkTableModifiable(tableName);
} catch (TableNotDisabledException ex) { } catch (TableNotDisabledException ex) {
if (eventType.isOnlineSchemaChangeSupported()) { if (isOnlineSchemaChangeAllowed()
&& eventType.isOnlineSchemaChangeSupported()) {
LOG.debug("Ignoring table not disabled exception " + LOG.debug("Ignoring table not disabled exception " +
"for supporting online schema changes."); "for supporting online schema changes.");
} else { } else {
@ -79,6 +80,11 @@ public abstract class TableEventHandler extends EventHandler {
this.tableNameStr = Bytes.toString(this.tableName); this.tableNameStr = Bytes.toString(this.tableName);
} }
private boolean isOnlineSchemaChangeAllowed() {
return this.server.getConfiguration().getBoolean(
"hbase.online.schema.update.enable", false);
}
@Override @Override
public void process() { public void process() {
try { try {

View File

@ -781,6 +781,16 @@
simplify coprocessor failure analysis. simplify coprocessor failure analysis.
</description> </description>
</property> </property>
<property>
<name>hbase.online.schema.update.enable</name>
<value>false</value>
<description>
Set true to enable online schema changes. This is an experimental feature.
There are known issues modifying table schemas at the same time a region
split is happening so your table needs to be quiescent or else you have to
be running with splits disabled.
</description>
</property>
<property> <property>
<name>dfs.support.append</name> <name>dfs.support.append</name>
<value>true</value> <value>true</value>
@ -788,6 +798,6 @@
This is an hdfs config. set in here so the hdfs client will do append support. This is an hdfs config. set in here so the hdfs client will do append support.
You must ensure that this config. is true serverside too when running hbase You must ensure that this config. is true serverside too when running hbase
(You will have to restart your cluster after setting it). (You will have to restart your cluster after setting it).
</description> </description>
</property> </property>
</configuration> </configuration>

View File

@ -308,6 +308,8 @@ public class TestAdmin {
@Test @Test
public void testOnlineChangeTableSchema() throws IOException, InterruptedException { public void testOnlineChangeTableSchema() throws IOException, InterruptedException {
final byte [] tableName = Bytes.toBytes("changeTableSchemaOnline"); final byte [] tableName = Bytes.toBytes("changeTableSchemaOnline");
TEST_UTIL.getMiniHBaseCluster().getMaster().getConfiguration().setBoolean(
"hbase.online.schema.update.enable", true);
HTableDescriptor [] tables = admin.listTables(); HTableDescriptor [] tables = admin.listTables();
int numTables = tables.length; int numTables = tables.length;
TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY); TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY);
@ -389,6 +391,38 @@ public class TestAdmin {
this.admin.listTables(); this.admin.listTables();
assertFalse(this.admin.tableExists(tableName)); assertFalse(this.admin.tableExists(tableName));
} }
@Test
public void testShouldFailOnlineSchemaUpdateIfOnlineSchemaIsNotEnabled()
throws Exception {
final byte[] tableName = Bytes.toBytes("changeTableSchemaOnlineFailure");
TEST_UTIL.getMiniHBaseCluster().getMaster().getConfiguration().setBoolean(
"hbase.online.schema.update.enable", false);
HTableDescriptor[] tables = admin.listTables();
int numTables = tables.length;
TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY);
tables = this.admin.listTables();
assertEquals(numTables + 1, tables.length);
// FIRST, do htabledescriptor changes.
HTableDescriptor htd = this.admin.getTableDescriptor(tableName);
// Make a copy and assert copy is good.
HTableDescriptor copy = new HTableDescriptor(htd);
assertTrue(htd.equals(copy));
// Now amend the copy. Introduce differences.
long newFlushSize = htd.getMemStoreFlushSize() / 2;
copy.setMemStoreFlushSize(newFlushSize);
final String key = "anyoldkey";
assertTrue(htd.getValue(key) == null);
copy.setValue(key, key);
boolean expectedException = false;
try {
modifyTable(tableName, copy);
} catch (TableNotDisabledException re) {
expectedException = true;
}
assertTrue("Online schema update should not happen.", expectedException);
}
/** /**
* Modify table is async so wait on completion of the table operation in master. * Modify table is async so wait on completion of the table operation in master.