diff --git a/CHANGES.txt b/CHANGES.txt
index fc8ff2eba16..fcdb03a6cc2 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -437,6 +437,7 @@ Release 0.92.0 - Unreleased
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
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
HBASE-4450 test for number of blocks read: to serve as baseline for expected
diff --git a/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java b/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java
index a88eb887adf..76c98b37222 100644
--- a/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java
+++ b/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java
@@ -69,7 +69,8 @@ public abstract class TableEventHandler extends EventHandler {
try {
this.masterServices.checkTableModifiable(tableName);
} catch (TableNotDisabledException ex) {
- if (eventType.isOnlineSchemaChangeSupported()) {
+ if (isOnlineSchemaChangeAllowed()
+ && eventType.isOnlineSchemaChangeSupported()) {
LOG.debug("Ignoring table not disabled exception " +
"for supporting online schema changes.");
} else {
@@ -79,6 +80,11 @@ public abstract class TableEventHandler extends EventHandler {
this.tableNameStr = Bytes.toString(this.tableName);
}
+ private boolean isOnlineSchemaChangeAllowed() {
+ return this.server.getConfiguration().getBoolean(
+ "hbase.online.schema.update.enable", false);
+ }
+
@Override
public void process() {
try {
diff --git a/src/main/resources/hbase-default.xml b/src/main/resources/hbase-default.xml
index 89113da122f..7de59d8c9ea 100644
--- a/src/main/resources/hbase-default.xml
+++ b/src/main/resources/hbase-default.xml
@@ -781,6 +781,16 @@
simplify coprocessor failure analysis.
+
+ hbase.online.schema.update.enable
+ false
+
+ 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.
+
+
dfs.support.append
true
@@ -788,6 +798,6 @@
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 will have to restart your cluster after setting it).
-
-
+
+
diff --git a/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java b/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
index 43f8a5014dc..e936b2ecb37 100644
--- a/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
+++ b/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
@@ -308,6 +308,8 @@ public class TestAdmin {
@Test
public void testOnlineChangeTableSchema() throws IOException, InterruptedException {
final byte [] tableName = Bytes.toBytes("changeTableSchemaOnline");
+ TEST_UTIL.getMiniHBaseCluster().getMaster().getConfiguration().setBoolean(
+ "hbase.online.schema.update.enable", true);
HTableDescriptor [] tables = admin.listTables();
int numTables = tables.length;
TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY);
@@ -389,6 +391,38 @@ public class TestAdmin {
this.admin.listTables();
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.