Broken connection leaked on database connection issue

Bug #1021064 reported by Gunnar Wagenknecht
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
BoneCP
Incomplete
Undecided
Unassigned

Bug Description

We hit a strange problem in 0.7.2 branch of BoneCP. When a connection breaks (for example, due to underlying database connection issues) our ConnectionHook#onMarkPossiblyBroken method is called. We've overridden the method in order to handle/detect MySQL state 08S01 (which is indicates connection problems) and return "ConnectionState.TERMINATE_ALL_CONNECTIONS". This will force the ConnectionHandle to call BoneCP#terminateAllConnections()

BoneCP#terminateAllConnections terminates all "free" connections. It looks like the current "in flight" (and broken) connection is not terminated. Turning on the watch thread confirms the issue.

Do we have to explicitly close the connection in our ConnectionHook implementation?

Revision history for this message
Gunnar Wagenknecht (g-u-w) wrote :

Hmm .... it may actually be the application that leaks the connection. We use Carbonado persistence layer and here is the relevant code:

        try {
            if (mOpenConnections == null) {
                throw new FetchException("Repository is closed");
            }

            JDBCTransaction txn = localTransactionScope().getTxn();
            if (txn != null) {
                // Return the connection used by the current transaction.
                return txn.getConnection();
            }

            // Get connection outside lock section since it may block.
            Connection con = mDataSource.getConnection();
            con.setAutoCommit(true);

            mOpenConnectionsLock.lock();
            try {
                if (mOpenConnections == null) {
                    con.close();
                    throw new FetchException("Repository is closed");
                }
                mOpenConnections.put(con, null);
            } finally {
                mOpenConnectionsLock.unlock();
            }

            return con;
        } catch (Exception e) {
            throw toFetchException(e);
        }

#setAutoCommit throws and SQLException (we don't test connections on checkout). This does not close the connection.

Revision history for this message
Wallace Wadge (wwadge) wrote :

Please also try with 0.8.0-beta1

Changed in bonecp:
status: New → Incomplete
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.