-
Notifications
You must be signed in to change notification settings - Fork 705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DeadLock on simultanously accessing uninitialized RefreshScope-Bean #383
Comments
Please try with the latest, RC2. |
Same result (the affected code didn't change as far as I can see). I attached the updated stack trace (the line numbers of GenericScope.BeanLifecycleWrapper were wrong in the old version): By the way: It doesn't have an effect on my issue, but as far as I can see in GenericScope.BeanLifecycleWrapper.getBean() double-check-locking is used without using an volatile synchronization object. As far as I known this is not thread safe. |
I'm unable to see the BLOCKED state. What do I need to do to see it? |
I simplified the Class, added some dokumentation and output. Hope now it's clear what happens |
I think we can safely call this a bug. But I'm not sure where to start fixing it. Arguably, there is no point having Sleuth applied to an |
GenericScope has some requirements to synchronize the bean creation and destruction phases, which exposes it to potential deadlocks (e.g. as reported in #383). The fact that the bean factory is also taking locks is taken advantage of to ensure that the same lock is taken on bean creation in all cases. So all threads have to wait for the same lock, and there is no danger of interleaving.
I put that change on a branch because I'm not sure it's finished (there's no test for instance), but I think it fixes this issue. |
@dsyer - we are running in to a similar issue. Can you please provide me details of the branch - so I can give it a shot ?. |
The change is linked to above my last comment. |
is this still a issue or fixed in latest version. |
The problem is actual for:
Is a fix for this issue expected in the near future? |
We are using the latest versions in our project but still facing this issue, deadlock at the same point, and it is occurring intermittently. Is there any workaround or fix. |
Hi!
I'm using version 2.0.0.M9. Sometimes my application runs into a deadlock. This happens when two threads are simultanously accessing an uninitialized
RefreshScope
Bean.My application uses the annotations
NewSpan
andAsync
. Both annotations cause access to aProbabilityBasedSampler
, that's provided asRefreshScope
-Bean byZipkinAutoConfiguration.RefreshScopedProbabilityBasedSamplerConfiguration.defaultTraceSampler(SamplerProperties)
.Thread 1 creates a Singleton-Bean, with a
@PostConstruct
calling a sampled method (@Async
-annotation). Thread 2 calls a sampled method (@NewSpan
-annotation).ProbabilityBasedSampler
andSamplerProperties
are not yet initialized.This is what happens:
Thread 1: tries to create the Singleton, accesses
DefaultSingletonBeanRegistry.getSingleton(String, ObjectFactory<?>)
and locksDefaultSingletonBeanRegistry.singletonObjects
Thread 2: calls a
@NewSpan
-annotated method. This requires theProbabilityBasedSampler
and triggersGenericScope.BeanLifecycleWrapper.getBean()
and locksGenericScope.BeanLifecycleWrapper.name
Thread 2: to create
ProbabilityBasedSampler
theSamplerProperties
are required. The bean factory tries to get theSamplerProperties
-Singleton, but has to wait for the lock onDefaultSingletonBeanRegistry.singletonObjects
that is held by Thread 1Thread 1: the
@PostConstruct
calls a@Async
-annotated method, that requiresProbabilityBasedSampler
. that triggersGenericScope.BeanLifecycleWrapper.getBean()
, but has to wait for the lockGenericScope.BeanLifecycleWrapper.name
held by Thread 2I attach a class that simulates the behaviour of my application setup and the stack trace when this class runs into the deadlock: RefreshScopeDeadLock.zip
The text was updated successfully, but these errors were encountered: