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

[GOBBLIN-1596] Ignore already exists exception if the table has already been created… #3451

Merged
merged 2 commits into from
Jan 14, 2022
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 @@ -276,14 +276,16 @@ private boolean ensureHiveTableExistenceBeforeAlternation(String tableName, Stri
Table table) throws TException, IOException{
try (AutoCloseableHiveLock lock = this.locks.getTableLock(dbName, tableName)) {
try {
if(!existsTable(dbName, tableName, client)) {
if (!existsTable(dbName, tableName, client)) {
try (Timer.Context context = this.metricContext.timer(CREATE_HIVE_TABLE).time()) {
client.createTable(getTableWithCreateTimeNow(table));
log.info(String.format("Created Hive table %s in db %s", tableName, dbName));
return true;
}
}
}catch (TException e) {
} catch (AlreadyExistsException ignore) {
// Table already exists, continue
Copy link
Contributor

@umustafi umustafi Jan 13, 2022

Choose a reason for hiding this comment

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

edit: I realize this case will be apparent from the logs if we see the log statement about "table already exists" without the log statement "unable to create hive table..."

} catch (TException e) {
log.error(
String.format("Unable to create Hive table %s in db %s: " + e.getMessage(), tableName, dbName), e);
throw e;
Expand Down Expand Up @@ -477,7 +479,8 @@ private void createOrAlterTable(IMetaStoreClient client, Table table, HiveSpec s
}

public boolean existsTable(String dbName, String tableName, IMetaStoreClient client) throws IOException {
if (this.optimizedChecks && this.tableAndDbExistenceCache.getIfPresent(dbName + ":" + tableName ) != null ) {
Boolean tableExits = this.tableAndDbExistenceCache.getIfPresent(dbName + ":" + tableName );
if (this.optimizedChecks && tableExits != null && tableExits) {
return true;
}
try {
Expand Down