You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2024/03/10 13:27:51 UTC
(hbase) branch master updated: HBASE-28395 TableNotFoundException when executing 'hbase hbck' (#5706)
This is an automated email from the ASF dual-hosted git repository.
zhangduo 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 76c632c6d1c HBASE-28395 TableNotFoundException when executing 'hbase hbck' (#5706)
76c632c6d1c is described below
commit 76c632c6d1c505b670da375681eb605437d233ad
Author: guluo <lu...@qq.com>
AuthorDate: Sun Mar 10 21:27:44 2024 +0800
HBASE-28395 TableNotFoundException when executing 'hbase hbck' (#5706)
Signed-off-by: Duo Zhang <zh...@apache.org>
---
.../org/apache/hadoop/hbase/util/HBaseFsck.java | 5 ++
.../hadoop/hbase/util/hbck/ReplicationChecker.java | 4 ++
.../TestHBaseFsckWithoutTableHbaseReplication.java | 70 ++++++++++++++++++++++
3 files changed, 79 insertions(+)
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
index 31020cf4bce..0d24ef78376 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
@@ -2572,6 +2572,11 @@ public class HBaseFsck extends Configured implements Closeable {
private void checkAndFixReplication() throws ReplicationException, IOException {
ReplicationChecker checker = new ReplicationChecker(getConf(), zkw, connection, errors);
+
+ if (!checker.checkHasDataInQueues()) {
+ return;
+ }
+
checker.checkUnDeletedQueues();
if (checker.hasUnDeletedQueues() && this.fixReplication) {
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/hbck/ReplicationChecker.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/hbck/ReplicationChecker.java
index 497304a3111..f92631eb792 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/hbck/ReplicationChecker.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/hbck/ReplicationChecker.java
@@ -130,4 +130,8 @@ public class ReplicationChecker {
queueStorage.removePeerFromHFileRefs(peerId);
}
}
+
+ public boolean checkHasDataInQueues() throws ReplicationException {
+ return queueStorage.hasData();
+ }
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckWithoutTableHbaseReplication.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckWithoutTableHbaseReplication.java
new file mode 100644
index 00000000000..279962c934f
--- /dev/null
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckWithoutTableHbaseReplication.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.util;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseTestingUtil;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.replication.ReplicationStorageFactory;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.testclassification.MiscTests;
+import org.apache.hadoop.hbase.util.hbck.HbckTestingUtil;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
+
+@Category({ MiscTests.class, MediumTests.class })
+public class TestHBaseFsckWithoutTableHbaseReplication {
+
+ @ClassRule
+ public static final HBaseClassTestRule CLASS_RULE =
+ HBaseClassTestRule.forClass(TestHBaseFsckWithoutTableHbaseReplication.class);
+
+ @ClassRule
+ public static final TestName name = new TestName();
+
+ private static final HBaseTestingUtil UTIL = new HBaseTestingUtil();
+ private static final TableName tableName =
+ TableName.valueOf("replication_" + name.getMethodName());
+
+ @Before
+ public void setUp() throws Exception {
+ UTIL.getConfiguration().setBoolean("hbase.write.hbck1.lock.file", false);
+ UTIL.getConfiguration().set(ReplicationStorageFactory.REPLICATION_QUEUE_TABLE_NAME,
+ tableName.getNameAsString());
+ UTIL.startMiniCluster(1);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ UTIL.shutdownMiniCluster();
+ }
+
+ @Test
+ public void test() throws Exception {
+ assertFalse(UTIL.getAdmin().tableExists(tableName));
+ HBaseFsck hBaseFsck = HbckTestingUtil.doFsck(UTIL.getConfiguration(), true);
+ assertEquals(0, hBaseFsck.getRetCode());
+ }
+}