deniskuzZ commented on a change in pull request #2647:
URL: https://github.com/apache/hive/pull/2647#discussion_r710079309



##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -369,32 +369,36 @@ public void setConf(Configuration conf){
     this.conf = conf;
 
     synchronized (TxnHandler.class) {
+      int maxPoolSize = MetastoreConf.getIntVar(conf, 
ConfVars.CONNECTION_POOLING_MAX_CONNECTIONS);
+      long getConnectionTimeoutMs = 30000;
       if (connPool == null) {
-        Connection dbConn = null;
-        // Set up the JDBC connection pool
-        try {
-          int maxPoolSize = MetastoreConf.getIntVar(conf, 
ConfVars.CONNECTION_POOLING_MAX_CONNECTIONS);
-          long getConnectionTimeoutMs = 30000;
-          connPool = setupJdbcConnectionPool(conf, maxPoolSize, 
getConnectionTimeoutMs);
-          /*the mutex pools should ideally be somewhat larger since some 
operations require 1
+        connPool = setupJdbcConnectionPool(conf, maxPoolSize, 
getConnectionTimeoutMs);
+      }
+
+      if (connPoolMutex == null) {
+        /*the mutex pools should ideally be somewhat larger since some 
operations require 1
            connection from each pool and we want to avoid taking a connection 
from primary pool
            and then blocking because mutex pool is empty.  There is only 1 
thread in any HMS trying
            to mutex on each MUTEX_KEY except MUTEX_KEY.CheckLock.  The 
CheckLock operation gets a
            connection from connPool first, then connPoolMutex.  All others, go 
in the opposite
            order (not very elegant...).  So number of connection requests for 
connPoolMutex cannot
            exceed (size of connPool + MUTEX_KEY.values().length - 1).*/
-          connPoolMutex = setupJdbcConnectionPool(conf, maxPoolSize + 
MUTEX_KEY.values().length, getConnectionTimeoutMs);
-          dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED);
+        connPoolMutex = setupJdbcConnectionPool(conf, maxPoolSize + 
MUTEX_KEY.values().length, getConnectionTimeoutMs);
+      }
+
+      if (dbProduct == null) {
+        try (Connection dbConn = 
getDbConn(Connection.TRANSACTION_READ_COMMITTED)) {
           determineDatabaseProduct(dbConn);
-          sqlGenerator = new SQLGenerator(dbProduct, conf);
         } catch (SQLException e) {
           String msg = "Unable to instantiate JDBC connection pooling, " + 
e.getMessage();

Review comment:
       Should we update the exception text here as you are handling pooling 
exceptions inside of setupJdbcConnectionPool, like ````Unable to determine 
database product```` ?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to