Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » 2.0.0: application hangs in acquire connection
2.0.0: application hangs in acquire connection [message #507405] Wed, 13 January 2010 11:53 Go to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 807
Registered: July 2009
Senior Member
Naturally because this is done in the EDT, this blocks the whole GUI. But it's not a long running thread, so running it in the EDT is ok.
Why oh why does it hang here?


"AWT-EventQueue-0" prio=6 tid=0x38feac00 nid=0xb54 in Object.wait()
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at org.eclipse.persistence.sessions.server.ConnectionPool.acqui reConnect
ion(ConnectionPool.java:102)
- locked <0x066782b8> (a org.eclipse.persistence.sessions.server.Connect
ionPool)
at org.eclipse.persistence.sessions.server.ServerSession.acquir eClientCo
nnection(ServerSession.java:241)
at org.eclipse.persistence.internal.sessions.ExclusiveIsolatedC lientSess
ion.executeCall(ExclusiveIsolatedClientSession.java:58)
at org.eclipse.persistence.internal.queries.DatasourceCallQuery Mechanism
..executeCall(DatasourceCallQueryMechanism.java:205)
at org.eclipse.persistence.internal.queries.DatasourceCallQuery Mechanism
..executeCall(DatasourceCallQueryMechanism.java:191)
at org.eclipse.persistence.internal.queries.DatasourceCallQuery Mechanism
..selectOneRow(DatasourceCallQueryMechanism.java:638)
at org.eclipse.persistence.internal.queries.ExpressionQueryMech anism.sel
ectOneRowFromTable(ExpressionQueryMechanism.java:2582)
at org.eclipse.persistence.internal.queries.ExpressionQueryMech anism.sel
ectOneRow(ExpressionQueryMechanism.java:2553)
at org.eclipse.persistence.queries.ReadObjectQuery.executeObjec tLevelRea
dQuery(ReadObjectQuery.java:431)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute DatabaseQ
uery(ObjectLevelReadQuery.java:997)
at org.eclipse.persistence.queries.DatabaseQuery.execute(Databa seQuery.j
ava:675)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute (ObjectLe
velReadQuery.java:958)
at org.eclipse.persistence.queries.ReadObjectQuery.execute(Read ObjectQue
ry.java:399)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute InUnitOfW
ork(ObjectLevelReadQuery.java:1021)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.int ernalExec
uteQuery(UnitOfWorkImpl.java:2863)
at org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuer
y(AbstractSession.java:1225)
at org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuer
y(AbstractSession.java:1207)
at org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuer
y(AbstractSession.java:1167)
at org.eclipse.persistence.internal.sessions.AbstractSession.re adObject(
AbstractSession.java:2743)
at org.eclipse.persistence.internal.sessions.MergeManager.regis terObject
ForMergeCloneIntoWorkingCopy(MergeManager.java:847)
at org.eclipse.persistence.internal.sessions.MergeManager.merge ChangesOf
CloneIntoWorkingCopy(MergeManager.java:473)
at org.eclipse.persistence.internal.sessions.MergeManager.merge Changes(M
ergeManager.java:267)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.mer geCloneWi
thReferences(UnitOfWorkImpl.java:3486)
at org.eclipse.persistence.internal.sessions.RepeatableWriteUni tOfWork.m
ergeCloneWithReferences(RepeatableWriteUnitOfWork.java:301)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.mer geCloneWi
thReferences(UnitOfWorkImpl.java:3446)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.merge Internal(
EntityManagerImpl.java:414)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.merge (EntityMa
nagerImpl.java:391)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at nl.knowledgeplaza.util.jpa.EntityManagerExtender.invoke(Enti tyManager
Extender.java:124)
at $Proxy4.merge(Unknown Source)
at org.tbee.swing.jpa.JpaObjectNavigatorModel$1.call(JpaObjectN avigatorM
odel.java:866)
at org.tbee.swing.jpa.JpaObjectNavigatorModel.doSave(JpaObjectN avigatorM
odel.java:886)
at org.tbee.swing.jpa.JpaObjectNavigatorModel.doSave(JpaObjectN avigatorM
odel.java:839)
at org.tbee.swing.jpa.JpaObjectNavigatorBar$3.actionPerformed(J paObjectN
avigatorBar.java:157)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unk nown Sour
ce)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)



This is the rest of the thread dump

Full thread dump Java HotSpot(TM) Client VM (14.0-b16 mixed mode):

"Foxtrot Multi Worker Thread Runner #1" daemon prio=6 tid=0x39f57800 nid=0x440 i
n Object.wait()
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:485)
at foxtrot.workers.SingleWorkerThread.takeTask(SingleWorkerThre ad.java:1
32)
- locked <0x0a132530> (a foxtrot.workers.MultiWorkerThread)
at foxtrot.workers.SingleWorkerThread.run(SingleWorkerThread.ja va:180)
at java.lang.Thread.run(Unknown Source)

"Thread-6 StateChecker" prio=6 tid=0x3a049400 nid=0xf48 waiting on condition
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at nl.reinders.Reinders$6.run(Reinders.java:597)
at java.lang.Thread.run(Unknown Source)

"ESTOS Timeouter" daemon prio=6 tid=0x3917dc00 nid=0x2f8 waiting on condition
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at nl.knowledgeplaza.util.ThreadUtil.sleepForced(ThreadUtil.jav a:244)
at nl.knowledgeplaza.util.ThreadUtil.sleepForced(ThreadUtil.jav a:224)
at nl.reinders.estos.EstosWrapper.timeouter(EstosWrapper.java:9 07)
at nl.reinders.estos.EstosWrapper.access$500(EstosWrapper.java: 43)
at nl.reinders.estos.EstosWrapper$3.run(EstosWrapper.java:871)
at java.lang.Thread.run(Unknown Source)

"ESTOS Dispatcher" daemon prio=6 tid=0x390f8000 nid=0x2d8 runnable
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
- locked <0x081fdc28> (a java.io.InputStreamReader)
at java.io.InputStreamReader.read(Unknown Source)
at java.io.BufferedReader.fill(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
- locked <0x081fdc28> (a java.io.InputStreamReader)
at java.io.BufferedReader.readLine(Unknown Source)
at nl.reinders.estos.EstosWrapper.dispatch(EstosWrapper.java:78 7)
at nl.reinders.estos.EstosWrapper.access$400(EstosWrapper.java: 43)
at nl.reinders.estos.EstosWrapper$2.run(EstosWrapper.java:751)
at java.lang.Thread.run(Unknown Source)

"D3D Screen Updater" daemon prio=8 tid=0x38fbf400 nid=0xa68 in Object.wait()
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at sun.java2d.d3d.D3DScreenUpdateManager.run(Unknown Source)
- locked <0x06640f88> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

"TimerQueue" daemon prio=6 tid=0x38fac400 nid=0x9cc in Object.wait()
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at javax.swing.TimerQueue.run(Unknown Source)
- locked <0x06630c38> (a javax.swing.TimerQueue)
at java.lang.Thread.run(Unknown Source)

"DestroyJavaVM" prio=6 tid=0x002ba000 nid=0xf0 waiting on condition

java.lang.Thread.State: RUNNABLE


"AWT-Windows" daemon prio=6 tid=0x38fc7800 nid=0xcc4 runnable
java.lang.Thread.State: RUNNABLE
at sun.awt.windows.WToolkit.eventLoop(Native Method)
at sun.awt.windows.WToolkit.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

"AWT-Shutdown" prio=6 tid=0x38f21000 nid=0xcc0 in Object.wait()
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:485)
at sun.awt.AWTAutoShutdown.run(Unknown Source)
- locked <0x064ae388> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

"Java2D Disposer" daemon prio=10 tid=0x38f3c400 nid=0x884 in Object.wait()
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked <0x064ae418> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at sun.java2d.Disposer.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

"Low Memory Detector" daemon prio=6 tid=0x38974800 nid=0x120 runnable
java.lang.Thread.State: RUNNABLE

"CompilerThread0" daemon prio=10 tid=0x3896e400 nid=0x928 waiting on condition [
0x00000000]
java.lang.Thread.State: RUNNABLE

"Attach Listener" daemon prio=10 tid=0x3896d000 nid=0xa58 runnable
java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x3896bc00 nid=0x57c waiting on condition

java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=8 tid=0x3895b400 nid=0xc38 in Object.wait()

java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked <0x064ae648> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)

"Reference Handler" daemon prio=10 tid=0x38956800 nid=0xdf4 in Object.wait() [0x
38a7f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:485)
at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)
- locked <0x064ade70> (a java.lang.ref.Reference$Lock)

"VM Thread" prio=10 tid=0x38953800 nid=0xba8 runnable

"VM Periodic Task Thread" prio=10 tid=0x3897ec00 nid=0xb1c waiting on condition


JNI global references: 2381

Heap
def new generation total 18240K, used 14538K [0x02990000, 0x03d50000, 0x064a0
000)
eden space 16256K, 84% used [0x02990000, 0x0370dff8, 0x03970000)
from space 1984K, 36% used [0x03970000, 0x03a24be0, 0x03b60000)
to space 1984K, 0% used [0x03b60000, 0x03b60000, 0x03d50000)
tenured generation total 241984K, used 65503K [0x064a0000, 0x150f0000, 0x3299
0000)
the space 241984K, 27% used [0x064a0000, 0x0a497c68, 0x0a497e00, 0x150f0000)

compacting perm gen total 38144K, used 38032K [0x32990000, 0x34ed0000, 0x36990
000)
the space 38144K, 99% used [0x32990000, 0x34eb4270, 0x34eb4400, 0x34ed0000)
No shared spaces configured.
Re: 2.0.0: application hangs in acquire connection [message #507471 is a reply to message #507405] Wed, 13 January 2010 15:36 Go to previous messageGo to next message
Doug Clarke is currently offline Doug ClarkeFriend
Messages: 155
Registered: July 2009
Senior Member
Tom,

The line of code where the thread is blocked waiting is due to there being no available connections in the pool. How do you have the pool configured?

Doug
Re: 2.0.0: application hangs in acquire connection [message #507480 is a reply to message #507405] Wed, 13 January 2010 15:53 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1039
Registered: July 2009
Senior Member
Hello,

This thread lock/wait will appear because the thread is trying to acquire a connection from a pool that has run out, and so waits until one is released. It is strange that the thread dump shows no other EclipseLink process running, so I do not see how this would occur without configuration or customization on your connection pools. Can you post the settings you are using?

Best Regards,
Chris

Re: 2.0.0: application hangs in acquire connection [message #507485 is a reply to message #507471] Wed, 13 January 2010 15:59 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 807
Registered: July 2009
Senior Member
> The line of code where the thread is blocked waiting is due to there
> being no available connections in the pool. How do you have the pool
> configured?

static public EntityManagerFactory createEntityManagerFactory(Class jdbcDriver, String jdbcUrl, String jdbcUsr, String jdbcPwd)
{
// setup the factory
if (log4j.isInfoEnabled()) log4j.info("Creating EntityManagerFactory for " + jdbcUsr + " @ " + ReindersInformixAndLoggingDriver.PREFIX + jdbcDriver.getName() + "#" + jdbcUrl);
// setup the factory
Map<String, Object> lOptions = new HashMap<String, Object>();
// always use ReindersInformixAndLoggingDriver so it hooks in the special informix connection class (which will automatically use the log4j driver)
lOptions.put(PersistenceUnitProperties.JDBC_DRIVER, ReindersInformixAndLoggingDriver.class.getName());
lOptions.put(PersistenceUnitProperties.JDBC_URL, ReindersInformixAndLoggingDriver.PREFIX + jdbcDriver.getName() + "#" + jdbcUrl);
lOptions.put(PersistenceUnitProperties.JDBC_USER, jdbcUsr);
lOptions.put(PersistenceUnitProperties.JDBC_PASSWORD, jdbcPwd);
lOptions.put(PersistenceUnitProperties.TARGET_DATABASE, InformixPlatform.class.getName());
lOptions.put(PersistenceUnitProperties.TARGET_SERVER, TargetServer.None);

// this may cause problems: when a transaction fails (e.g. not null constraint) the sequences are rollback as well, but the entities keep their assigned PK's. Hence the counters run out of sync with the PK's
lOptions.put(PersistenceUnitProperties.JDBC_SEQUENCE_CONNECT ION_POOL, "true"); // force sequences to use a separate pool
lOptions.put(PersistenceUnitProperties.EXCLUSIVE_CONNECTION_ MODE, "Always"); // reads and write should go through the same connection, otherwise batchtransfer will have connection conflicts

lOptions.put(PersistenceUnitProperties.CACHE_SHARED_DEFAULT, "false"); // do not use the shared cache (otherwise refresh will not update from db) //lOptions.put(PersistenceUnitProperties.BATCH_WRITING, "JDBC"); // use batch writing as a performance increase
//lOptions.put(PersistenceUnitProperties.LOGGING_LEVEL, "fine"); // set loggingleven
lOptions.put(PersistenceUnitProperties.ALLOW_ZERO_ID, "true"); // allow zero to be used as an @Id
final EntityManagerFactory lEntityManagerFactory = Persistence.createEntityManagerFactory("reinders", lOptions);

// done
return lEntityManagerFactory;
}

static public EntityManager createEntityManager(EntityManagerFactory entityManagerFactory)
{
Map<String, String> lOptions = new HashMap<String, String>();
//lOptions.put(org.eclipse.persistence.config.EntityManagerP roperties.JOIN_EXISTING_TRANSACTION, "true"); // reads and write should go through the same connection
EntityManager lEntityManagerActual = entityManagerFactory.createEntityManager(lOptions);
EntityManager lEntityManager = EclipselinkEntityManagerExtender.wrap( lEntityManagerActual );
// make sure all entitymanagers have flushmode commit
// In EclipseLink 1.1 there is a persistence unit property for this, "eclipselink.persistence-context.flush-mode"="COMMIT"
lEntityManager.setFlushMode(FlushModeType.COMMIT);

// access eclipselink (Toplink) specials
JpaEntityManager lJpaEntityManager = (JpaEntityManager)lEntityManagerActual;
// setup the history policy
HistoryPolicy lHistoryPolicy = new HistoryPolicy();
lHistoryPolicy.setShouldUseDatabaseTime(true);
lHistoryPolicy.addStartFieldName("relation.hstvalidfrom");
lHistoryPolicy.addEndFieldName("relation.hstvaliduntil");
lHistoryPolicy.addHistoryTableName("relation", "reindershst:relation");
lJpaEntityManager.getSession().getClassDescriptor(nl.reinder s.bm.Relation.class).setHistoryPolicy(lHistoryPolicy);

// register DescriptorEventListenerRouter on all entities
for (Class lClass : cEntityClasses)
{
lJpaEntityManager.getSession().getClassDescriptor(lClass).ge tEventManager().addListener( cEclipselinkDescriptorEventListenerRouter );
}

// done
iEntityManagerToUsername.put(lEntityManager, iEntityManagerFactoryToUsername.get(entityManagerFactory));
return lEntityManager;
}
Re: 2.0.0: application hangs in acquire connection [message #507490 is a reply to message #507485] Wed, 13 January 2010 16:40 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1039
Registered: July 2009
Senior Member
How are you closing entitymanagers? Connections will not be released until the EntityManger is closed so that the underlying exclusive connection can be released. It also seems odd that you have session and descriptor configuration in the createEntityManager method. If this method is called multiple times, event listeners will be added to the same descriptors multiple times - it might be better to move this to a customizer method so that it is only run once.

Best Regards,
Chris
Re: 2.0.0: application hangs in acquire connection [message #507532 is a reply to message #507490] Wed, 13 January 2010 18:31 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 807
Registered: July 2009
Senior Member
On 2010-01-13 17:40, Chris Delahunt wrote:
> How are you closing entitymanagers? Connections will not be released
> until the EntityManger is closed so that the underlying exclusive
> connection can be released.

I think I'm closing the EM when the frame they are bound to is closed, but I will need to verify.

Adding the exclusive connection is a change I recently made, on a suggestion by James, because of a rollback on the sequences table.
Maybe I should reinstate the "join existing transaction" I used before without troubles.


> It also seems odd that you have session and
> descriptor configuration in the createEntityManager method. If this
> method is called multiple times, event listeners will be added to the
> same descriptors multiple times - it might be better to move this to a
> customizer method so that it is only run once.

Good point. I will need to check that.

Valueable suggestions.

Tom
Re: 2.0.0: application hangs in acquire connection [message #507541 is a reply to message #507490] Wed, 13 January 2010 19:29 Go to previous message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 807
Registered: July 2009
Senior Member
On 2010-01-13 17:40, Chris Delahunt wrote:
> How are you closing entitymanagers?

When the frame is closed. Check.

> It also seems odd that you have session and
> descriptor configuration in the createEntityManager method. If this
> method is called multiple times, event listeners will be added to the
> same descriptors multiple times - it might be better to move this to a
> customizer method so that it is only run once.

Moved that to the method createEntityManagerFactory method. That is only called once. Created one EM in that method just for binding these.

Reverted back to the join existing transaction; see how that goes.

Tom
Previous Topic:Incorrect SQL syntax for a "JOIN FETCH" JPQL
Next Topic:ReadAllQuery not working for in-memory db
Goto Forum:
  


Current Time: Tue Dec 23 00:13:24 GMT 2014

Powered by FUDForum. Page generated in 0.01871 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software