[infinispan-issues] [JBoss JIRA] (ISPN-2033) JdbcBinaryCacheStore.purgeInternal() - releaseConnection() should be called in finally block.

Jim Dunkerton (JIRA) jira-events at lists.jboss.org
Fri May 4 10:34:18 EDT 2012


     [ https://issues.jboss.org/browse/ISPN-2033?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jim Dunkerton updated ISPN-2033:
--------------------------------

    Description: 
A potential memory leak of pooled DB connections is present in JdbcBinaryCacheStore.  Observe the catch and finally blocks of the purgeInternal() method.  The pooled DB connection is not released unless an SQLException has been thrown.  Contrast with JdbcStringBasedCacheStore.purgeInternal(), where the releaseConnection() is invoked in the finally block.

When using a JdbcMixedCacheStore, I noticed a DB connection leak.  It appeared that for every two connections being acquired, only one was being released.  I believe it is down to the fact that the JdbcBinaryCacheStore inside the JdbcMixedCacheStore is not releasing its connections properly (i.e. in its finally block) whereas the JdbcStringBasedCacheStore is.

I guess a workaround is to use only a JdbcStringBasedCacheStore, not a JdbcMixedCacheStore.


  was:
A potential memory leak of pooled DB connections is present in JdbcCacheBinaryStore.  Observe the catch and finally blocks of the purgeInternal() method:

    catch (SQLException ex) {
         //if something happens make sure buckets locks are being release
         releaseLocks(expiredBuckets);
         connectionFactory.releaseConnection(conn);
         log.failedClearingJdbcCacheStore(ex);
         throw new CacheLoaderException("Failed clearing JdbcBinaryCacheStore", ex);
      } finally {
         JdbcUtil.safeClose(ps);
         JdbcUtil.safeClose(rs);
      }

The pooled DB connection is not released unless an SQLException has been thrown.

Contrast with JdbcStringBasedCacheStore.purgeInternal():

} catch (SQLException ex) {
         log.failedClearingJdbcCacheStore(ex);
         throw new CacheLoaderException("Failed clearing string based JDBC store", ex);
      } finally {
         JdbcUtil.safeClose(ps);
         connectionFactory.releaseConnection(conn);
      }

When using a JdbcMixedCacheStore, I noticed a DB connection leak.  It appeared that for every two connections being acquired, only one was being released.  I believe it is down to the fact that the JdbcBinaryCacheStore inside the JdbcMixedCacheStore is not releasing its connections properly (i.e. in its finally block) whereas the JdbcStringBasedCacheStore is.

I guess a workaround is to use only a JdbcStringBasedCacheStore, not a JdbcMixedCacheStore.



    
> JdbcBinaryCacheStore.purgeInternal() - releaseConnection() should be called in finally block.
> ---------------------------------------------------------------------------------------------
>
>                 Key: ISPN-2033
>                 URL: https://issues.jboss.org/browse/ISPN-2033
>             Project: Infinispan
>          Issue Type: Bug
>          Components: Loaders and Stores
>    Affects Versions: 5.1.2.FINAL
>         Environment: JBoss 7.1.1 Final
>            Reporter: Jim Dunkerton
>            Assignee: Manik Surtani
>              Labels: cache, connection_pool, database
>
> A potential memory leak of pooled DB connections is present in JdbcBinaryCacheStore.  Observe the catch and finally blocks of the purgeInternal() method.  The pooled DB connection is not released unless an SQLException has been thrown.  Contrast with JdbcStringBasedCacheStore.purgeInternal(), where the releaseConnection() is invoked in the finally block.
> When using a JdbcMixedCacheStore, I noticed a DB connection leak.  It appeared that for every two connections being acquired, only one was being released.  I believe it is down to the fact that the JdbcBinaryCacheStore inside the JdbcMixedCacheStore is not releasing its connections properly (i.e. in its finally block) whereas the JdbcStringBasedCacheStore is.
> I guess a workaround is to use only a JdbcStringBasedCacheStore, not a JdbcMixedCacheStore.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the infinispan-issues mailing list