This is an automated email from the ASF dual-hosted git repository.
ndimiduk pushed a commit to branch branch-3
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-3 by this push:
new 3160b36ffd7 HBASE-28687 BackupSystemTable#checkSystemTable should
ensure system tables are enabled (#6018)
3160b36ffd7 is described below
commit 3160b36ffd72e7143734ba3434e3a727b0658a4e
Author: Ray Mattingly <[email protected]>
AuthorDate: Wed Jun 26 08:40:12 2024 -0400
HBASE-28687 BackupSystemTable#checkSystemTable should ensure system tables
are enabled (#6018)
Co-authored-by: Ray Mattingly <[email protected]>
Signed-off-by: Bryan Beaudreault <[email protected]>
Signed-off-by: Nick Dimiduk <[email protected]>
---
.../hbase/backup/impl/BackupSystemTable.java | 13 ++++++++
.../apache/hadoop/hbase/backup/TestBackupBase.java | 37 +++++++++++++++++++++-
2 files changed, 49 insertions(+), 1 deletion(-)
diff --git
a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupSystemTable.java
b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupSystemTable.java
index c364316d54e..5a12b45a586 100644
---
a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupSystemTable.java
+++
b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupSystemTable.java
@@ -47,6 +47,7 @@ import org.apache.hadoop.hbase.NamespaceExistException;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableExistsException;
import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.TableNotDisabledException;
import org.apache.hadoop.hbase.backup.BackupInfo;
import org.apache.hadoop.hbase.backup.BackupInfo.BackupState;
import org.apache.hadoop.hbase.backup.BackupRestoreConstants;
@@ -207,10 +208,12 @@ public final class BackupSystemTable implements Closeable
{
TableDescriptor backupHTD =
BackupSystemTable.getSystemTableDescriptor(conf);
createSystemTable(admin, backupHTD);
}
+ ensureTableEnabled(admin, tableName);
if (!admin.tableExists(bulkLoadTableName)) {
TableDescriptor blHTD =
BackupSystemTable.getSystemTableForBulkLoadedDataDescriptor(conf);
createSystemTable(admin, blHTD);
}
+ ensureTableEnabled(admin, bulkLoadTableName);
waitForSystemTable(admin, tableName);
waitForSystemTable(admin, bulkLoadTableName);
}
@@ -1889,4 +1892,14 @@ public final class BackupSystemTable implements
Closeable {
}
return Bytes.toBytes(sb.toString());
}
+
+ private static void ensureTableEnabled(Admin admin, TableName tableName)
throws IOException {
+ if (!admin.isTableEnabled(tableName)) {
+ try {
+ admin.enableTable(tableName);
+ } catch (TableNotDisabledException ignored) {
+ LOG.info("Table {} is not disabled, ignoring enable request",
tableName);
+ }
+ }
+ }
}
diff --git
a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java
b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java
index e9c1cfd9c32..ed17ef8a117 100644
---
a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java
+++
b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java
@@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.backup;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -57,6 +58,7 @@ import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
import org.apache.hadoop.hbase.master.cleaner.LogCleaner;
import org.apache.hadoop.hbase.master.cleaner.TimeToLiveLogCleaner;
+import org.apache.hadoop.hbase.regionserver.LogRoller;
import
org.apache.hadoop.hbase.security.HadoopSecurityEnabledUserProviderForTesting;
import org.apache.hadoop.hbase.security.UserProvider;
import org.apache.hadoop.hbase.security.access.SecureTestUtil;
@@ -67,6 +69,7 @@ import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.wal.AbstractFSWALProvider;
import org.apache.hadoop.hbase.wal.WALFactory;
import org.junit.AfterClass;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -115,6 +118,38 @@ public class TestBackupBase {
super(conn, backupId, request);
}
+ @Before
+ public void ensurePreviousBackupTestsAreCleanedUp() throws Exception {
+ // Every operation here may not be necessary for any given test,
+ // some often being no-ops. the goal is to help ensure atomicity
+ // of that tests that implement TestBackupBase
+ try (BackupAdmin backupAdmin = getBackupAdmin()) {
+ backupManager.finishBackupSession();
+ backupAdmin.listBackupSets().forEach(backupSet -> {
+ try {
+ backupAdmin.deleteBackupSet(backupSet.getName());
+ } catch (IOException ignored) {
+ }
+ });
+ } catch (Exception ignored) {
+ }
+ Arrays.stream(TEST_UTIL.getAdmin().listTableNames())
+ .filter(tableName -> !tableName.isSystemTable()).forEach(tableName -> {
+ try {
+ TEST_UTIL.truncateTable(tableName);
+ } catch (IOException ignored) {
+ }
+ });
+ TEST_UTIL.getMiniHBaseCluster().getRegionServerThreads().forEach(rst -> {
+ try {
+ LogRoller walRoller = rst.getRegionServer().getWalRoller();
+ walRoller.requestRollAll();
+ walRoller.waitUntilWalRollFinished();
+ } catch (Exception ignored) {
+ }
+ });
+ }
+
@Override
public void execute() throws IOException {
// case INCREMENTAL_COPY:
@@ -468,7 +503,7 @@ public class TestBackupBase {
}
}
- protected BackupAdmin getBackupAdmin() throws IOException {
+ protected static BackupAdmin getBackupAdmin() throws IOException {
return new BackupAdminImpl(TEST_UTIL.getConnection());
}