This is an automated email from the ASF dual-hosted git repository.
zihanli58 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/gobblin.git
The following commit(s) were added to refs/heads/master by this push:
new 44a7e1a [GOBBLIN-1596] Ignore already exists exception if the table
has already been created… (#3451)
44a7e1a is described below
commit 44a7e1a27cc73387cf309487f45895801984059d
Author: William Lo <[email protected]>
AuthorDate: Thu Jan 13 17:05:48 2022 -0800
[GOBBLIN-1596] Ignore already exists exception if the table has already
been created… (#3451)
* Ignore already exists exception if the table has already been created by
another thread or job entirely
* Address review + add concurrency fix
---
.../gobblin/hive/metastore/HiveMetaStoreBasedRegister.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git
a/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreBasedRegister.java
b/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreBasedRegister.java
index 3e21e44..f70aa9c 100644
---
a/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreBasedRegister.java
+++
b/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreBasedRegister.java
@@ -276,14 +276,16 @@ public class HiveMetaStoreBasedRegister extends
HiveRegister {
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
+ } catch (TException e) {
log.error(
String.format("Unable to create Hive table %s in db %s: " +
e.getMessage(), tableName, dbName), e);
throw e;
@@ -477,7 +479,8 @@ public class HiveMetaStoreBasedRegister extends
HiveRegister {
}
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 {