This is an automated email from the ASF dual-hosted git repository.

okumin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new b395fc7f8a0 HIVE-28749: The default hikaricp.leakDetectionThreshold is 
not valid (#5639) (Shohei Okumiya, reviewed by Stamatis Zampetakis, Zhihua Deng)
b395fc7f8a0 is described below

commit b395fc7f8a03a47ced2ca6f5679a8a6ac2f3eb08
Author: Shohei Okumiya <[email protected]>
AuthorDate: Fri Feb 14 10:57:57 2025 +0900

    HIVE-28749: The default hikaricp.leakDetectionThreshold is not valid 
(#5639) (Shohei Okumiya, reviewed by Stamatis Zampetakis, Zhihua Deng)
---
 .../datasource/HikariCPDataSourceProvider.java     | 13 ++---------
 .../datasource/TestDataSourceProviderFactory.java  | 26 ++++++++++++++++++++--
 2 files changed, 26 insertions(+), 13 deletions(-)

diff --git 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/HikariCPDataSourceProvider.java
 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/HikariCPDataSourceProvider.java
index b09094cc58a..91f1ea3d557 100644
--- 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/HikariCPDataSourceProvider.java
+++ 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/HikariCPDataSourceProvider.java
@@ -40,8 +40,6 @@ public class HikariCPDataSourceProvider implements 
DataSourceProvider {
   private static final Logger LOG = 
LoggerFactory.getLogger(HikariCPDataSourceProvider.class);
 
   static final String HIKARI = "hikaricp";
-  private static final String CONNECTION_TIMEOUT_PROPERTY = HIKARI + 
".connectionTimeout";
-  private static final String LEAK_DETECTION_THRESHOLD = HIKARI + 
".leakDetectionThreshold";
 
   @Override
   public DataSource create(Configuration hdpConfig, int maxPoolSize) throws 
SQLException {
@@ -52,10 +50,7 @@ public DataSource create(Configuration hdpConfig, int 
maxPoolSize) throws SQLExc
     String user = DataSourceProvider.getMetastoreJdbcUser(hdpConfig);
     String passwd = DataSourceProvider.getMetastoreJdbcPasswd(hdpConfig);
 
-    Properties properties = replacePrefix(
-        DataSourceProvider.getPrefixedProperties(hdpConfig, HIKARI));
-    long connectionTimeout = hdpConfig.getLong(CONNECTION_TIMEOUT_PROPERTY, 
30000L);
-    long leakDetectionThreshold = hdpConfig.getLong(LEAK_DETECTION_THRESHOLD, 
3600000L);
+    Properties properties = 
replacePrefix(DataSourceProvider.getPrefixedProperties(hdpConfig, HIKARI));
 
     HikariConfig config;
     try {
@@ -67,7 +62,6 @@ public DataSource create(Configuration hdpConfig, int 
maxPoolSize) throws SQLExc
     config.setJdbcUrl(driverUrl);
     config.setUsername(user);
     config.setPassword(passwd);
-    config.setLeakDetectionThreshold(leakDetectionThreshold);
     if (!StringUtils.isEmpty(poolName)) {
       config.setPoolName(poolName);
     }
@@ -79,13 +73,10 @@ public DataSource create(Configuration hdpConfig, int 
maxPoolSize) throws SQLExc
     // so that the connection pool can retire the idle connection aggressively,
     // this will make Metastore more scalable especially if there is a leader 
in the warehouse.
     if ("mutex".equals(poolName)) {
-      int minimumIdle = Integer.valueOf(hdpConfig.get(HIKARI + ".minimumIdle", 
"2"));
+      int minimumIdle = Integer.parseInt(hdpConfig.get(HIKARI + 
".minimumIdle", "2"));
       config.setMinimumIdle(Math.min(maxPoolSize, minimumIdle));
     }
 
-    //https://github.com/brettwooldridge/HikariCP
-    config.setConnectionTimeout(connectionTimeout);
-
     DatabaseProduct dbProduct =  
DatabaseProduct.determineDatabaseProduct(driverUrl, hdpConfig);
 
     String s = dbProduct.getPrepareTxnStmt();
diff --git 
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/datasource/TestDataSourceProviderFactory.java
 
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/datasource/TestDataSourceProviderFactory.java
index 0c4b6d35713..90bd3aeb5d0 100644
--- 
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/datasource/TestDataSourceProviderFactory.java
+++ 
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/datasource/TestDataSourceProviderFactory.java
@@ -63,9 +63,27 @@ public void testNoDataSourceCreatedWithoutProps() throws 
SQLException {
   }
 
   @Test
-  public void testSetHikariCpLeakDetectionThresholdProperty() throws 
SQLException {
+  public void testDefaultHikariCpProperties() throws SQLException {
+    MetastoreConf.setVar(conf, ConfVars.CONNECTION_POOLING_TYPE, 
HikariCPDataSourceProvider.HIKARI);
+
+    DataSourceProvider dsp = 
DataSourceProviderFactory.tryGetDataSourceProviderOrNull(conf);
+    Assert.assertNotNull(dsp);
+
+    DataSource ds = dsp.create(conf);
+    Assert.assertTrue(ds instanceof HikariDataSource);
+    HikariDataSource hds = (HikariDataSource) ds;
+    Assert.assertEquals(30000L, hds.getConnectionTimeout());
+    Assert.assertEquals(1800000L, hds.getMaxLifetime());
+    Assert.assertEquals(0L, hds.getLeakDetectionThreshold());
+    Assert.assertEquals(1L, hds.getInitializationFailTimeout());
+  }
+
+  @Test
+  public void testSetHikariCpProperties() throws SQLException {
 
     MetastoreConf.setVar(conf, ConfVars.CONNECTION_POOLING_TYPE, 
HikariCPDataSourceProvider.HIKARI);
+    conf.set(HikariCPDataSourceProvider.HIKARI + ".connectionTimeout", "2000");
+    conf.set(HikariCPDataSourceProvider.HIKARI + ".maxLifetime", "50000");
     conf.set(HikariCPDataSourceProvider.HIKARI + ".leakDetectionThreshold", 
"3600");
     conf.set(HikariCPDataSourceProvider.HIKARI + ".initializationFailTimeout", 
"-1");
 
@@ -74,7 +92,11 @@ public void testSetHikariCpLeakDetectionThresholdProperty() 
throws SQLException
 
     DataSource ds = dsp.create(conf);
     Assert.assertTrue(ds instanceof HikariDataSource);
-    Assert.assertEquals(3600L, 
((HikariDataSource)ds).getLeakDetectionThreshold());
+    HikariDataSource hds = (HikariDataSource) ds;
+    Assert.assertEquals(2000L, hds.getConnectionTimeout());
+    Assert.assertEquals(50000L, hds.getMaxLifetime());
+    Assert.assertEquals(3600L, hds.getLeakDetectionThreshold());
+    Assert.assertEquals(-1L, hds.getInitializationFailTimeout());
   }
 
   @Test

Reply via email to