You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by bb...@apache.org on 2023/09/13 15:17:58 UTC
[hbase] branch branch-3 updated: HBASE-28079 Unhandled TableExistsException and NamespaceExistException in BackupSystemTable (#5399)
This is an automated email from the ASF dual-hosted git repository.
bbeaudreault 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 c674c073eea HBASE-28079 Unhandled TableExistsException and NamespaceExistException in BackupSystemTable (#5399)
c674c073eea is described below
commit c674c073eea03527d143bcabeeda44c291a261c8
Author: Bryan Beaudreault <bb...@apache.org>
AuthorDate: Wed Sep 13 11:12:52 2023 -0400
HBASE-28079 Unhandled TableExistsException and NamespaceExistException in BackupSystemTable (#5399)
Signed-off-by: Duo Zhang <zh...@apache.org>
---
.../hbase/backup/impl/BackupSystemTable.java | 26 +++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
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 04f43b5b0ea..55f225f41cf 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
@@ -43,7 +43,9 @@ import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.NamespaceDescriptor;
+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.backup.BackupInfo;
import org.apache.hadoop.hbase.backup.BackupInfo.BackupState;
@@ -202,17 +204,28 @@ public final class BackupSystemTable implements Closeable {
Configuration conf = connection.getConfiguration();
if (!admin.tableExists(tableName)) {
TableDescriptor backupHTD = BackupSystemTable.getSystemTableDescriptor(conf);
- admin.createTable(backupHTD);
+ createSystemTable(admin, backupHTD);
}
if (!admin.tableExists(bulkLoadTableName)) {
TableDescriptor blHTD = BackupSystemTable.getSystemTableForBulkLoadedDataDescriptor(conf);
- admin.createTable(blHTD);
+ createSystemTable(admin, blHTD);
}
waitForSystemTable(admin, tableName);
waitForSystemTable(admin, bulkLoadTableName);
}
}
+ private void createSystemTable(Admin admin, TableDescriptor descriptor) throws IOException {
+ try {
+ admin.createTable(descriptor);
+ } catch (TableExistsException e) {
+ // swallow because this class is initialized in concurrent environments (i.e. bulkloads),
+ // so may be subject to race conditions where one caller succeeds in creating the
+ // table and others fail because it now exists
+ LOG.debug("Table {} already exists, ignoring", descriptor.getTableName(), e);
+ }
+ }
+
private void verifyNamespaceExists(Admin admin) throws IOException {
String namespaceName = tableName.getNamespaceAsString();
NamespaceDescriptor ns = NamespaceDescriptor.create(namespaceName).build();
@@ -225,7 +238,14 @@ public final class BackupSystemTable implements Closeable {
}
}
if (!exists) {
- admin.createNamespace(ns);
+ try {
+ admin.createNamespace(ns);
+ } catch (NamespaceExistException e) {
+ // swallow because this class is initialized in concurrent environments (i.e. bulkloads),
+ // so may be subject to race conditions where one caller succeeds in creating the
+ // namespace and others fail because it now exists
+ LOG.debug("Namespace {} already exists, ignoring", ns.getName(), e);
+ }
}
}