[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] EclipseLink lockup in exclusive isolated session mode

Hi Andrei,

thank you for helping me.
Please adjust the testcase to reproduce the bug:

     public void testExclusiveSessionRunOutOfConnections() {
         EntityManager em = createEntityManager("customfeatures");

//because a change/(bug?) in EL 2.1, it's important to set the pool name to null
//that EL will really disable internal connection pooling
((ClientSession) ((EntityManagerImpl) em).getUnitOfWork()
.getParent()).getConnectionPolicy().setPoolName(null);


boolean loop = true;
while(loop) {
em.clear(); // it's important that clear() is invoked "between" a transaction
beginTransaction(em);
// Employee emp = em.find(Employee.class, 1);
// List<Employee> employees = em.createQuery("SELECT
OBJECT(e) FROM Employee e").getResultList();
List names = em.createNativeQuery("SELECT NAME FROM
CUSTOM_FEATURE_EMPLOYEE").getResultList();
commitTransaction(em);
}
}




Best regards,
Patric


Zitat von Andrei Ilitchev <andrei.ilitchev@xxxxxxxxxx>:

I can't reproduce running out of connections:

persistence.xml:

<persistence xmlns="http://java.sun.com/xml/ns/persistence"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_1_0.xsd" version="1.0">
<persistence-unit name="customfeatures" transaction-type="RESOURCE_LOCAL">


<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

<class>org.eclipse.persistence.testing.models.jpa.customfeatures.Employee</class>
<properties>
<property name="eclipselink.session.customizer" value="org.eclipse.persistence.testing.models.jpa.customfeatures.Customizer"/>
<property name="eclipselink.jdbc.exclusive-connection.mode" value="Always"/>
</properties>
</persistence-unit>


</persistence>


The testing framework I am using passes user/password/url to createEntityManagerFactory method.
I am creating a data source in customizer:
public class Customizer implements SessionCustomizer {
public void customize(Session session) throws SQLException {
OracleDataSource ds = new OracleDataSource();
ds.setURL(session.getLogin().getConnectionString());
session.getLogin().setConnector(new JNDIConnector(ds));
session.getLogin().useExternalConnectionPooling();
}
}


The test runs forever using the same connection all the time no matter is it find, query or native query.
public void testExclusiveSessionRunOutOfConnections() {
EntityManager em = createEntityManager("customfeatures");
boolean loop = true;
while(loop) {
beginTransaction(em);
// Employee emp = em.find(Employee.class, 1);
// List<Employee> employees = em.createQuery("SELECT OBJECT(e) FROM Employee e").getResultList();
List names = em.createNativeQuery("SELECT NAME FROM CUSTOM_FEATURE_EMPLOYEE").getResultList();
commitTransaction(em);
}
}


And I've got another question: will EntityManager.close() release/close
the acquired connection in the exclusive isolated mode?
Yes.

On 12/9/2010 9:27 AM, patric@xxxxxxxxxxx wrote:
Hello,

I am experiencing a critical issue when using the exclusive isolated
session mode which results in a lockup during a database call.

To reproduce it, do the following:

1. Enable exclusive isolated session mode (property
eclipselink.jdbc.exclusive-connection.mode = Always) and use the
external connection pool mode
2. Use a non-JTA Datasource
3. Begin EntityManager transaction
4. Do a JPA Operation (e.g. find())
5. Commit the EntityManager transaction
6. Repeat steps 3-5 several times (ca. 50)
=> database call will lock.

I investigated this issue and it seems that a EntityManager transaction
commit will not release the connection hold by the exclusive isolated
client session (which is fine and expected).
But, due to the "resetted" transaction it will acquire a new one than
re-using the acquired one.

After some iterations, maxNumberOfNonPooledConnections will be exceeded,
which will end up that the ServerSession will wait forever for obtaining
a new connection in the wait() call.

Here's the stacktrace for the issue:
Thread [Thread-3] (Suspended)
waiting for: ServerSession (id=313)
Object.wait(long) line: not available [native method]
ServerSession(Object).wait() line: 474
ServerSession.acquireClientConnection(ClientSession) line: 268
ExclusiveIsolatedClientSession(ClientSession).basicBeginTransaction()
line: 123
ExclusiveIsolatedClientSession(AbstractSession).beginTransaction() line:
552
RepeatableWriteUnitOfWork(UnitOfWorkImpl).beginTransaction() line: 509
RepeatableWriteUnitOfWork(UnitOfWorkImpl).beginEarlyTransaction() line: 499
EJBQueryImpl.executeReadQuery() line: 383
EJBQueryImpl.getResultList() line: 568
...

And I've got another question: will EntityManager.close() release/close
the acquired connection in the exclusive isolated mode?


I really appreciate your help.

Best regards,
Patric


_______________________________________________ eclipselink-users mailing list eclipselink-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users