Re: [T5 5.3.6] Dead Lock while initializing tapestry

2013-04-18 Thread Arunas F
No, not at all. New Thread is spawned at some moment while initializing 
T5 app. And there is nothing special about a code:



new Thread(new Runnable() {

@Override
public void run() {
if (logger.isDebugEnabled()) logger.debug(etlName + " 
initializing... ");


try {

for (EtlAbstractJob job : jobs.getJobs()) {
job.initialize();
}

} catch (EtlJobException e) {
logger.error(e.toString());
e.printStackTrace();
}

if (logger.isDebugEnabled()) logger.debug(etlName + " 
finished initialization... ");

}

}).start();


And in the code  at line "job.initialize();" the var job are T5 IOC 
services and these services depend on MongoDB service at some deeper level.


public class ReportStorageImpl implements ReportStorage {

.

private MongoDB mongoDB;

public ReportStorageImpl(MongoDB mongoDB) {
this.mongoDB = mongoDB;
}

..

@Override
public MongoDB getMongoDB() {
return mongoDB;
}
}

About MongoDB also nothing special. The module is taken from 
https://github.com/mlusetti/tapestry-mongodb-core (look at earlier 
revisions).



BR,
Arunas


On 18/04/2013 18:53, mailingl...@j-b-s.de wrote:

Are you spawning a new thread in your MongoDBImpl.java:30 which makes use of T5 
services, too? From the Stacktrace you are (well T5 IOC is) building the 
mongodb service right now. What happens in the ctor of your class? Can you 
paste some code??

Jens

Sent from my iPhone

On 18.04.2013, at 17:31, Arunas F  wrote:


Hi,

We are using T5 version 5.3.6. I found that Tapestry runs into a dead lock 
while building registry (initializing) if I start a new Thread what uses some 
T5 services.
Right now we have disabled multi threading while initializing app. But I would 
like to know, is it a T5 bug and I should file it into JIRA or this is an 
expected behavior and it is a T5 limitation.


Problem description: If the T5 registry and new Thread tries to create same 
service (from proxy) simultaneously sometimes you can run into deadlock and T5 
app wont initialize. In the stacktrace dump below, you can find that  both 
threads tried to create MongoDB instance and ran into a deadlock.


Found one Java-level deadlock:
=
"Thread-10":
  waiting for ownable synchronizer 0x0007c27e65f0, (a 
java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync),
  which is held by "Thread-4"
"Thread-4":
  waiting to lock monitor 0x7fdf5b91c658 (object 0x0007eda35c20, a 
org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator),
  which is held by "Thread-10"

Java stack information for the threads listed above:
===
"Thread-10":
at sun.misc.Unsafe.park(Native Method)
- parking to wait for  <0x0007c27e65f0> (a 
java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at 
java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834)
at 
java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireShared(AbstractQueuedSynchronizer.java:964)
at 
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireShared(AbstractQueuedSynchronizer.java:1282)
at 
java.util.concurrent.locks.ReentrantReadWriteLock$ReadLock.lock(ReentrantReadWriteLock.java:731)
at 
org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:75)
at 
org.apache.tapestry5.ioc.internal.ModuleImpl.findOrCreate(ModuleImpl.java:213)
at 
org.apache.tapestry5.ioc.internal.ModuleImpl.getService(ModuleImpl.java:109)
at 
org.apache.tapestry5.ioc.internal.RegistryImpl.getService(RegistryImpl.java:421)
at 
org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:868)
at 
org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:57)
at 
org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateInjection(InternalUtils.java:257)
at 
org.apache.tapestry5.ioc.internal.util.InternalUtils.access$000(InternalUtils.java:50)
at 
org.apache.tapestry5.ioc.internal.util.InternalUtils$4.invoke(InternalUtils.java:289)
at 
org.apache.tapestry5.ioc.internal.util.InternalUtils$4.invoke(InternalUtils.java:286)
at 
org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
at 
org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
at 
org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
at 
org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameters(Internal

[T5 5.3.6] Dead Lock while initializing tapestry

2013-04-18 Thread Arunas F
rom space 16768K, 0% used 
[0x0007fdb8,0x0007fdb8,0x0007febe)
  to   space 20800K, 0% used 
[0x0007fc34,0x0007fc34,0x0007fd79)
 ParOldGen   total 100864K, used 55724K [0x0007c000, 
0x0007c628, 0x0007eaab)
  object space 100864K, 55% used 
[0x0007c000,0x0007c366b120,0x0007c628)
 PSPermGen   total 77120K, used 40052K [0x0007b000, 
0x0007b4b5, 0x0007c000)
  object space 77120K, 51% used 
[0x0007b000,0x0007b271d388,0x0007b4b50000)

2013-04-18 17:18:42
Full thread dump Java HotSpot(TM) 64-Bit Server VM (23.0-b21 mixed mode):


Best regards,
Arunas F