Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-28079 Unhandled TableExistsException and NamespaceExistException in BackupSystemTable #5399

Merged
merged 2 commits into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
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;
Expand Down Expand Up @@ -202,17 +204,28 @@ private void checkSystemTable() throws IOException {
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add more comments to say why here we could hit table exists exception?

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();
Expand All @@ -225,7 +238,14 @@ private void verifyNamespaceExists(Admin admin) throws IOException {
}
}
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);
}
}
}

Expand Down