Possible Bug in Minerva ObjectPool

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible Bug in Minerva ObjectPool

maburger
Hi *,

we're facing a transaction problem with long running services which do not use the tranactionnal connection for a long time (>1800000l). The Minerva connection pool implementation releases connections although they are in use. Here the possible wrong code sniped from the ObjectPool.class. In my opinion the second condition "rec.isInUse()" has to be inverted.

 void runGCandShrink() {
...

            if (runGC) { // Garbage collection - return any object that's been out too long with no use
                Iterator it = objsCopy.iterator();
                while (it.hasNext()) {
                    ObjectRecord rec = (ObjectRecord) it.next();
                    if (rec != null && rec.isInUse() && rec.getMillisSinceLastUse() >= gcMinIdleMillis) {
                        releaseObject(rec.getClientObject());
                    }
                }
            }
...

The causes the system to throw the following Exception when another process tries to use the current released connection:

2008-10-10 09:46:06,963 [     XAResourceImpl.java:318:ERROR] attempt to inactive start resource with existing xid; current xid: [globalId=ffffff9d10000005748415420444f2057452043414c4c2049543f0000000000000000000000000000000000000,branchId=300000005748415420444f2057452043414c4c2049543f0000000000000000000000000000000000000], new xid: [globalId=7220000005748415420444f2057452043414c4c2049543f0000000000000000000000000000000000000,branchId=200000005748415420444f2057452043414c4c2049543f0000000000000000000000000000000000000]
2008-10-10 09:46:06,963 [    TransactionImpl.java:177:WARN ] Unable to enlist XAResource org.ofbiz.minerva.pool.jdbc.xa.wrapper.XAResourceImpl@f49e8f, errorCode: -4
javax.transaction.xa.XAException
        at org.ofbiz.minerva.pool.jdbc.xa.wrapper.XAResourceImpl.throwXAException(XAResourceImpl.java:334)
        at org.ofbiz.minerva.pool.jdbc.xa.wrapper.XAResourceImpl.start(XAResourceImpl.java:319)
        at org.apache.geronimo.transaction.manager.TransactionImpl.enlistResource(TransactionImpl.java:173)
        at org.apache.geronimo.transaction.context.InheritableTransactionContext.enlistResource(InheritableTransactionContext.java:92)
        at org.apache.geronimo.transaction.context.GeronimoTransactionDelegate.enlistResource(GeronimoTransactionDelegate.java:59)
        at org.ofbiz.minerva.pool.jdbc.xa.XAConnectionFactory.prepareObject(XAConnectionFactory.java:390)
        at org.ofbiz.minerva.pool.ObjectPool.getObject(ObjectPool.java:649)
        at org.ofbiz.minerva.pool.jdbc.xa.XAPoolDataSource.getConnection(XAPoolDataSource.java:363)
        at org.ofbiz.entity.transaction.MinervaConnectionFactory.getConnection(MinervaConnectionFactory.java:122)
        at org.ofbiz.geronimo.GeronimoTransactionFactory.getConnection(GeronimoTransactionFactory.java:91)
        at org.ofbiz.entity.transaction.TransactionFactory.getConnection(TransactionFactory.java:92)
        at org.ofbiz.entity.jdbc.ConnectionFactory.getConnection(ConnectionFactory.java:69)
        at org.ofbiz.entity.jdbc.SQLProcessor.getConnection(SQLProcessor.java:256)
        at org.ofbiz.entity.jdbc.SQLProcessor.prepareStatement(SQLProcessor.java:362)
        at org.ofbiz.entity.datasource.GenericDAO.selectListIteratorByCondition(GenericDAO.java:752)
        at org.ofbiz.entity.datasource.GenericHelperDAO.findListIteratorByCondition(GenericHelperDAO.java:140)
        at org.ofbiz.entity.GenericDelegator.findListIteratorByCondition(GenericDelegator.java:1805)
        at org.ofbiz.entity.GenericDelegator.findByCondition(GenericDelegator.java:1705)
        at org.ofbiz.entity.GenericDelegator.findByCondition(GenericDelegator.java:1684)
Reply | Threaded
Open this post in threaded view
|

Re: Possible Bug in Minerva ObjectPool

Jacques Le Roux
Administrator
FYI, Minerva has been replaced by Apache DBCP in OFBiz OOTB since more one year now.
Nevertheless, this is maybe an interesting information for people still using Minerva

Jacques

From: "maburger" <[hidden email]>

>
> Hi *,
>
> we're facing a transaction problem with long running services which do not
> use the tranactionnal connection for a long time (>1800000l). The Minerva
> connection pool implementation releases connections although they are in
> use. Here the possible wrong code sniped from the ObjectPool.class. In my
> opinion the second condition "rec.isInUse()" has to be inverted.
>
> void runGCandShrink() {
> ...
>
>            if (runGC) { // Garbage collection - return any object that's
> been out too long with no use
>                Iterator it = objsCopy.iterator();
>                while (it.hasNext()) {
>                    ObjectRecord rec = (ObjectRecord) it.next();
>                    if (rec != null && rec.isInUse() &&
> rec.getMillisSinceLastUse() >= gcMinIdleMillis) {
>                        releaseObject(rec.getClientObject());
>                    }
>                }
>            }
> ...
>
> The causes the system to throw the following Exception when another process
> tries to use the current released connection:
>
> 2008-10-10 09:46:06,963 [     XAResourceImpl.java:318:ERROR] attempt to
> inactive start resource with existing xid; current xid:
> [globalId=ffffff9d10000005748415420444f2057452043414c4c2049543f0000000000000000000000000000000000000,branchId=300000005748415420444f2057452043414c4c2049543f0000000000000000000000000000000000000],
> new xid:
> [globalId=7220000005748415420444f2057452043414c4c2049543f0000000000000000000000000000000000000,branchId=200000005748415420444f2057452043414c4c2049543f0000000000000000000000000000000000000]
> 2008-10-10 09:46:06,963 [    TransactionImpl.java:177:WARN ] Unable to
> enlist XAResource
> org.ofbiz.minerva.pool.jdbc.xa.wrapper.XAResourceImpl@f49e8f, errorCode: -4
> javax.transaction.xa.XAException
> at
> org.ofbiz.minerva.pool.jdbc.xa.wrapper.XAResourceImpl.throwXAException(XAResourceImpl.java:334)
> at
> org.ofbiz.minerva.pool.jdbc.xa.wrapper.XAResourceImpl.start(XAResourceImpl.java:319)
> at
> org.apache.geronimo.transaction.manager.TransactionImpl.enlistResource(TransactionImpl.java:173)
> at
> org.apache.geronimo.transaction.context.InheritableTransactionContext.enlistResource(InheritableTransactionContext.java:92)
> at
> org.apache.geronimo.transaction.context.GeronimoTransactionDelegate.enlistResource(GeronimoTransactionDelegate.java:59)
> at
> org.ofbiz.minerva.pool.jdbc.xa.XAConnectionFactory.prepareObject(XAConnectionFactory.java:390)
> at org.ofbiz.minerva.pool.ObjectPool.getObject(ObjectPool.java:649)
> at
> org.ofbiz.minerva.pool.jdbc.xa.XAPoolDataSource.getConnection(XAPoolDataSource.java:363)
> at
> org.ofbiz.entity.transaction.MinervaConnectionFactory.getConnection(MinervaConnectionFactory.java:122)
> at
> org.ofbiz.geronimo.GeronimoTransactionFactory.getConnection(GeronimoTransactionFactory.java:91)
> at
> org.ofbiz.entity.transaction.TransactionFactory.getConnection(TransactionFactory.java:92)
> at
> org.ofbiz.entity.jdbc.ConnectionFactory.getConnection(ConnectionFactory.java:69)
> at org.ofbiz.entity.jdbc.SQLProcessor.getConnection(SQLProcessor.java:256)
> at
> org.ofbiz.entity.jdbc.SQLProcessor.prepareStatement(SQLProcessor.java:362)
> at
> org.ofbiz.entity.datasource.GenericDAO.selectListIteratorByCondition(GenericDAO.java:752)
> at
> org.ofbiz.entity.datasource.GenericHelperDAO.findListIteratorByCondition(GenericHelperDAO.java:140)
> at
> org.ofbiz.entity.GenericDelegator.findListIteratorByCondition(GenericDelegator.java:1805)
> at
> org.ofbiz.entity.GenericDelegator.findByCondition(GenericDelegator.java:1705)
> at
> org.ofbiz.entity.GenericDelegator.findByCondition(GenericDelegator.java:1684)
> --
> View this message in context: http://www.nabble.com/Possible-Bug-in-Minerva-ObjectPool-tp19955172p19955172.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>