Hi all it seems there is a raise condition when realizing lazy loaded
services.

The race is between JustInTimeObjectCreator.obtainObjectFromCreator /
ConcurrentBarrier and requires a shared service.

When a proxy is instantiated JustInTimeObjectCreator.createObject is called
which is synchronized. Eventually this method will
call ModuleImpl.findOrCreate which will first acquire a global read lock
(ConcurrentBarrier.withRead) to check if the service is available and if
not it will acquire a global write lock  (ConcurrentBarrier.withWrite) and
finally instantiate.

An example that will deadlock is the following

Thread A
1. Calls a method from service A
2. JustInTimeObjectCreator.createObject of service A called
3. ConcurrentBarrier.withRead called
4. ConcurrentBarrier.withWrite called
5. Service A constructor called
6. On the constructor we call a method from Service B
7. JustInTimeObjectCreator.createObject of Service B called
8. Cannot proceed since its waiting from synchronization of Thread B (See
below) JustInTimeObjectCreator.createObject to complete

Thread B (comes after step 3 of thread A)
1. Calls a method from service B
2. JustInTimeObjectCreator.createObject of service B called
3. ConcurrentBarrier.withRead called cannot proceed due to being locked
from Thread A

I managed to find two issues reported already with the exact same issue
1. https://www.mail-archive.com/users@tapestry.apache.org/msg77239.html
2.
https://mail-archives.apache.org/mod_mbox/tapestry-users/201310.mbox/browser

Thanks

Reply via email to