From f52cb32f5f0c9e31b5addf29adbb886ca6d167dd Mon Sep 17 00:00:00 2001 From: jsbali Date: Fri, 24 Sep 2021 02:15:24 +0530 Subject: [PATCH] [HUDI-2248] Fixing the closing of hms client (#3364) * [HUDI-2248] Fixing the closing of hms client * [HUDI-2248] Using Hive.closeCurrent() over client.close() --- .../org/apache/hudi/hive/HiveMetastoreBasedLockProvider.java | 2 +- .../src/main/java/org/apache/hudi/hive/HoodieHiveClient.java | 2 +- .../test/java/org/apache/hudi/hive/testutils/TestCluster.java | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hudi-sync/hudi-hive-sync/src/main/java/org/apache/hudi/hive/HiveMetastoreBasedLockProvider.java b/hudi-sync/hudi-hive-sync/src/main/java/org/apache/hudi/hive/HiveMetastoreBasedLockProvider.java index a1279b2be898..f5bca97c3d4a 100644 --- a/hudi-sync/hudi-hive-sync/src/main/java/org/apache/hudi/hive/HiveMetastoreBasedLockProvider.java +++ b/hudi-sync/hudi-hive-sync/src/main/java/org/apache/hudi/hive/HiveMetastoreBasedLockProvider.java @@ -149,7 +149,7 @@ public void close() { if (lock != null) { hiveClient.unlock(lock.getLockid()); } - hiveClient.close(); + Hive.closeCurrent(); } catch (Exception e) { LOG.error(generateLogStatement(org.apache.hudi.common.lock.LockState.FAILED_TO_RELEASE, generateLogSuffixString())); } diff --git a/hudi-sync/hudi-hive-sync/src/main/java/org/apache/hudi/hive/HoodieHiveClient.java b/hudi-sync/hudi-hive-sync/src/main/java/org/apache/hudi/hive/HoodieHiveClient.java index 4f979fe519b2..2e9b86e967e3 100644 --- a/hudi-sync/hudi-hive-sync/src/main/java/org/apache/hudi/hive/HoodieHiveClient.java +++ b/hudi-sync/hudi-hive-sync/src/main/java/org/apache/hudi/hive/HoodieHiveClient.java @@ -295,7 +295,7 @@ public void close() { try { ddlExecutor.close(); if (client != null) { - client.close(); + Hive.closeCurrent(); client = null; } } catch (Exception e) { diff --git a/hudi-sync/hudi-hive-sync/src/test/java/org/apache/hudi/hive/testutils/TestCluster.java b/hudi-sync/hudi-hive-sync/src/test/java/org/apache/hudi/hive/testutils/TestCluster.java index a5631d044279..c059c63a6a6f 100644 --- a/hudi-sync/hudi-hive-sync/src/test/java/org/apache/hudi/hive/testutils/TestCluster.java +++ b/hudi-sync/hudi-hive-sync/src/test/java/org/apache/hudi/hive/testutils/TestCluster.java @@ -47,6 +47,7 @@ import org.apache.hadoop.hive.metastore.RetryingMetaStoreClient; import org.apache.hadoop.hive.metastore.api.Database; import org.apache.hadoop.hive.metastore.api.NoSuchObjectException; +import org.apache.hadoop.hive.ql.metadata.Hive; import org.apache.hive.service.server.HiveServer2; import org.apache.parquet.avro.AvroSchemaConverter; import org.apache.parquet.hadoop.ParquetWriter; @@ -265,7 +266,7 @@ public void startHiveServer2() { public void shutDown() { stopHiveServer2(); - client.close(); + Hive.closeCurrent(); hiveTestService.getHiveMetaStore().stop(); hdfsTestService.stop(); }