FAQ
Repository: hive
Updated Branches:
   refs/heads/master 50b6d0c6b -> edd630043


HIVE-11915 : BoneCP returns closed connections from the pool (Sergey Shelukhin, reviewed by Thejar M Nair)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/edd63004
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/edd63004
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/edd63004

Branch: refs/heads/master
Commit: edd63004375602bf7550513380ec25cf34ca5cf5
Parents: 50b6d0c
Author: Sergey Shelukhin <sershe@apache.org>
Authored: Wed Sep 30 15:23:25 2015 -0700
Committer: Sergey Shelukhin <sershe@apache.org>
Committed: Wed Sep 30 15:24:48 2015 -0700

----------------------------------------------------------------------
  .../hadoop/hive/metastore/txn/TxnHandler.java | 25 +++++++++++---------
  1 file changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/edd63004/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
----------------------------------------------------------------------
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java b/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
index 8597d9f..0b19368 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
@@ -84,6 +84,7 @@ public class TxnHandler {
    static final private Log LOG = LogFactory.getLog(TxnHandler.class.getName());

    static private DataSource connPool;
+ static private boolean doRetryOnConnPool = false;
    private final static Object lockLock = new Object(); // Random object to lock on for the lock
    // method

@@ -885,18 +886,19 @@ public class TxnHandler {

    }

- /**
- * Get a connection to the database
- * @param isolationLevel desired isolation level. If you are doing _any_ data modifications
- * you should request serializable, else read committed should be fine.
- * @return db connection
- * @throws MetaException if the connection cannot be obtained
- */
    protected Connection getDbConn(int isolationLevel) throws SQLException {
- Connection dbConn = connPool.getConnection();
- dbConn.setAutoCommit(false);
- dbConn.setTransactionIsolation(isolationLevel);
- return dbConn;
+ int rc = doRetryOnConnPool ? 10 : 1;
+ while (true) {
+ try {
+ Connection dbConn = connPool.getConnection();
+ dbConn.setAutoCommit(false);
+ dbConn.setTransactionIsolation(isolationLevel);
+ return dbConn;
+ } catch (SQLException e){
+ if ((--rc) <= 0) throw e;
+ LOG.error("There is a problem with a connection from the pool, retrying", e);
+ }
+ }
    }

    void rollbackDBConn(Connection dbConn) {
@@ -1964,6 +1966,7 @@ public class TxnHandler {
        config.setUser(user);
        config.setPassword(passwd);
        connPool = new BoneCPDataSource(config);
+ doRetryOnConnPool = true; // Enable retries to work around BONECP bug.
      } else if ("dbcp".equals(connectionPooler)) {
        ObjectPool objectPool = new GenericObjectPool();
        ConnectionFactory connFactory = new DriverManagerConnectionFactory(driverUrl, user, passwd);

Search Discussions

  • Sershe at Sep 30, 2015 at 11:11 pm
    Repository: hive
    Updated Branches:
       refs/heads/branch-1 fe569fc3c -> e9bc9d9f5


    HIVE-11915 : BoneCP returns closed connections from the pool (Sergey Shelukhin, reviewed by Thejar M Nair)


    Project: http://git-wip-us.apache.org/repos/asf/hive/repo
    Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/e9bc9d9f
    Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/e9bc9d9f
    Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/e9bc9d9f

    Branch: refs/heads/branch-1
    Commit: e9bc9d9f59194d23dcc9e426c3da914a6fb6d0eb
    Parents: fe569fc
    Author: Sergey Shelukhin <sershe@apache.org>
    Authored: Wed Sep 30 15:23:25 2015 -0700
    Committer: Sergey Shelukhin <sershe@apache.org>
    Committed: Wed Sep 30 15:27:17 2015 -0700

    ----------------------------------------------------------------------
      .../hadoop/hive/metastore/txn/TxnHandler.java | 25 +++++++++++---------
      1 file changed, 14 insertions(+), 11 deletions(-)
    ----------------------------------------------------------------------


    http://git-wip-us.apache.org/repos/asf/hive/blob/e9bc9d9f/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
    ----------------------------------------------------------------------
    diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java b/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
    index 30e9795..52cbda6 100644
    --- a/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
    +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
    @@ -84,6 +84,7 @@ public class TxnHandler {
        static final private Log LOG = LogFactory.getLog(TxnHandler.class.getName());

        static private DataSource connPool;
    + static private boolean doRetryOnConnPool = false;
        private final static Object lockLock = new Object(); // Random object to lock on for the lock
        // method

    @@ -885,18 +886,19 @@ public class TxnHandler {

        }

    - /**
    - * Get a connection to the database
    - * @param isolationLevel desired isolation level. If you are doing _any_ data modifications
    - * you should request serializable, else read committed should be fine.
    - * @return db connection
    - * @throws MetaException if the connection cannot be obtained
    - */
        protected Connection getDbConn(int isolationLevel) throws SQLException {
    - Connection dbConn = connPool.getConnection();
    - dbConn.setAutoCommit(false);
    - dbConn.setTransactionIsolation(isolationLevel);
    - return dbConn;
    + int rc = doRetryOnConnPool ? 10 : 1;
    + while (true) {
    + try {
    + Connection dbConn = connPool.getConnection();
    + dbConn.setAutoCommit(false);
    + dbConn.setTransactionIsolation(isolationLevel);
    + return dbConn;
    + } catch (SQLException e){
    + if ((--rc) <= 0) throw e;
    + LOG.error("There is a problem with a connection from the pool, retrying", e);
    + }
    + }
        }

        void rollbackDBConn(Connection dbConn) {
    @@ -1953,6 +1955,7 @@ public class TxnHandler {
            config.setUser(user);
            config.setPassword(passwd);
            connPool = new BoneCPDataSource(config);
    + doRetryOnConnPool = true; // Enable retries to work around BONECP bug.
          } else if ("dbcp".equals(connectionPooler)) {
            ObjectPool objectPool = new GenericObjectPool();
            ConnectionFactory connFactory = new DriverManagerConnectionFactory(driverUrl, user, passwd);

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categorieshive, hadoop
postedSep 30, '15 at 10:23p
activeSep 30, '15 at 11:11p
posts2
users1
websitehive.apache.org

1 user in discussion

Sershe: 2 posts

People

Translate

site design / logo © 2021 Grokbase