You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2020/10/29 23:34:50 UTC
[hbase] branch master updated: HBASE-24977 Meta table shouldn't be
modified as read only (#2537)
This is an automated email from the ASF dual-hosted git repository.
stack pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new e3beccf HBASE-24977 Meta table shouldn't be modified as read only (#2537)
e3beccf is described below
commit e3beccf1fcd3dcb1384afd7a98fd2ada0e4e2bc0
Author: Pankaj <pa...@apache.org>
AuthorDate: Fri Oct 30 05:04:23 2020 +0530
HBASE-24977 Meta table shouldn't be modified as read only (#2537)
Signed-off-by: stack <st...@apache.org>
---
.../hadoop/hbase/util/TableDescriptorChecker.java | 6 +++++
.../org/apache/hadoop/hbase/TestHBaseMetaEdit.java | 29 ++++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/TableDescriptorChecker.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/TableDescriptorChecker.java
index 906ae45..c69d38a 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/TableDescriptorChecker.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/TableDescriptorChecker.java
@@ -23,6 +23,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.CompoundConfiguration;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
import org.apache.hadoop.hbase.client.TableDescriptor;
@@ -150,6 +151,11 @@ public final class TableDescriptorChecker {
warnOrThrowExceptionForFailure(logWarn, message, null);
}
+ // Meta table shouldn't be set as read only, otherwise it will impact region assignments
+ if (td.isReadOnly() && TableName.isMetaTableName(td.getTableName())) {
+ warnOrThrowExceptionForFailure(false, "Meta table can't be set as read only.", null);
+ }
+
for (ColumnFamilyDescriptor hcd : td.getColumnFamilies()) {
if (hcd.getTimeToLive() <= 0) {
String message = "TTL for column family " + hcd.getNameAsString() + " must be positive.";
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHBaseMetaEdit.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHBaseMetaEdit.java
index 6977452..33c0f10 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHBaseMetaEdit.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHBaseMetaEdit.java
@@ -18,6 +18,7 @@
package org.apache.hadoop.hbase;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -28,6 +29,7 @@ import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
import org.apache.hadoop.hbase.client.RegionInfoBuilder;
import org.apache.hadoop.hbase.client.TableDescriptor;
+import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding;
import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.testclassification.MediumTests;
@@ -133,4 +135,31 @@ public class TestHBaseMetaEdit {
assertTrue(hioe.getMessage().contains("Delete of hbase:meta"));
}
}
+
+ /**
+ * Validate whether meta table can be altered as READ only, shouldn't be allowed otherwise it will
+ * break assignment functionalities. See HBASE-24977.
+ */
+ @Test
+ public void testAlterMetaWithReadOnly() throws IOException {
+ Admin admin = UTIL.getAdmin();
+ TableDescriptor origMetaTableDesc = admin.getDescriptor(TableName.META_TABLE_NAME);
+ assertFalse(origMetaTableDesc.isReadOnly());
+ TableDescriptor newTD =
+ TableDescriptorBuilder.newBuilder(origMetaTableDesc).setReadOnly(true).build();
+ try {
+ admin.modifyTable(newTD);
+ fail("Meta table can't be set as read only");
+ } catch (Exception e) {
+ assertFalse(admin.getDescriptor(TableName.META_TABLE_NAME).isReadOnly());
+ }
+
+ // Create a table to check region assignment & meta operation
+ TableName tableName = TableName.valueOf("tempTable");
+ TableDescriptor td = TableDescriptorBuilder.newBuilder(tableName).setReadOnly(true)
+ .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("f1")).build())
+ .build();
+ UTIL.getAdmin().createTable(td);
+ UTIL.deleteTable(tableName);
+ }
}