Open GoogleCodeExporter opened 9 years ago
Do you open new threads from injected cxtors (or in your Providers)? That can
introduce potential deadlock. There's nothing about assisted-inject that I
know of that would make it deadlock in standard usage.
Do you have the stack trace of the thread holding the InheritingState lock (as
opposed to waiting to hold it)?
Original comment by sberlin
on 24 Sep 2012 at 5:11
What's an "injected cxtors"?
None of our modules have any threading code, nor our constructor methods.
Ah, I think that is this thread?
"Thread-2610" prio=10 tid=0x00007f416430f000 nid=0xea3 runnable
[0x00007f416b9f8000]
java.lang.Thread.State: RUNNABLE
at java.lang.Class.getConstantPool(Native Method)
at java.lang.System$2.getConstantPool(System.java:1130)
at java.lang.reflect.Method.declaredAnnotations(Method.java:693)
- locked <0x0000000775db9c60> (a java.lang.reflect.Method)
at java.lang.reflect.Method.getAnnotation(Method.java:679)
at com.google.inject.spi.InjectionPoint.getAtInject(InjectionPoint.java:466)
at com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:664)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:356)
at com.google.inject.internal.MembersInjectorStore.createWithListeners(MembersInjectorStore.java:90)
at com.google.inject.internal.MembersInjectorStore.access$000(MembersInjectorStore.java:34)
at com.google.inject.internal.MembersInjectorStore$1.create(MembersInjectorStore.java:42)
at com.google.inject.internal.MembersInjectorStore$1.create(MembersInjectorStore.java:39)
at com.google.inject.internal.FailableCache$1.apply(FailableCache.java:39)
at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:549)
at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:419)
at com.google.inject.internal.util.$CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at com.google.inject.internal.FailableCache.get(FailableCache.java:50)
at com.google.inject.internal.MembersInjectorStore.get(MembersInjectorStore.java:65)
at com.google.inject.internal.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:73)
at com.google.inject.internal.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:28)
at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:36)
at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:32)
at com.google.inject.internal.FailableCache$1.apply(FailableCache.java:39)
at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:549)
at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:419)
at com.google.inject.internal.util.$CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at com.google.inject.internal.FailableCache.get(FailableCache.java:50)
at com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:49)
at com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:125)
at com.google.inject.internal.InjectorImpl.initializeBinding(InjectorImpl.java:507)
at com.google.inject.internal.AbstractBindingProcessor$Processor$1.run(AbstractBindingProcessor.java:159)
at com.google.inject.internal.ProcessedBindingData.initializeBindings(ProcessedBindingData.java:44)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:122)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106)
- locked <0x0000000608d609a0> (a com.google.inject.internal.InheritingState)
at com.google.inject.internal.InjectorImpl.createChildInjector(InjectorImpl.java:217)
at com.google.inject.internal.InjectorImpl.createChildInjector(InjectorImpl.java:224)
at com.google.inject.assistedinject.FactoryProvider2.getBindingFromNewInjector(FactoryProvider2.java:602)
at com.google.inject.assistedinject.FactoryProvider2.invoke(FactoryProvider2.java:625)
at $Proxy16.create(Unknown Source)
at ourcode
That's the only one that's running, within Guice, and has gone through the
FP2#invoke
Original comment by antony.s...@gmail.com
on 24 Sep 2012 at 5:14
Thread-2610 is definitely runnable and will eventually release the
InheritingState lock, so this isn't a deadlock situation - however the full
thread dump does show this lock is a bottleneck in your application. Can you
give more details about the User class, does it inject the injector or any
providers into its constructor? (This disables certain optimizations in the
AssistedInject code.)
Original comment by mccu...@gmail.com
on 24 Sep 2012 at 5:18
I'm really shocked if this is a bottle neck and not a dead lock issue as i
wouldn't have thought our load was that high, or that creating this injector
would take *that* long that it would cause our responses to start timing out.
Yes, it injects Injector, but no providers. It's field level injection.
Original comment by antony.s...@gmail.com
on 24 Sep 2012 at 5:23
Assisted-Injector can be very slow if the assisted object injects the Injector
(or Providers), because for every object creation it will need to create a
child injector (which, as you can see, isn't the fastest of operations). If
you can refactor your User class to not require the Injector (ie, only take the
dependencies it needs), this will speed things up massively. See
http://code.google.com/p/google-guice/issues/detail?id=435 for details.
Original comment by sberlin
on 24 Sep 2012 at 5:45
Ok, I guess we'll chalk this up to just "very slow" not dead lock, due to that
single running thread.
We already refactored to remove the assisted inject, but we'll try it just
without the injector first, and see what happens. (Turns out we weren't even
using it anymore).
Is using assisted with a factory like this at all slow, compared to
injector#injectMembers? If it is, I'd rather just refactor and remove it
entirely.
Original comment by antony.s...@gmail.com
on 24 Sep 2012 at 5:52
If the assisted object doesn't inject an Injector nor Providers, assisted
inject is a blip on the radar (comparable to a normal injection).
Original comment by sberlin
on 24 Sep 2012 at 5:55
Thanks for the timely help!
Original comment by antony.s...@gmail.com
on 24 Sep 2012 at 5:59
Original issue reported on code.google.com by
antony.s...@gmail.com
on 24 Sep 2012 at 4:48Attachments: