-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
@Parallel not working for multiple factory beans #2867
Comments
Just FYI |
@graemerocher This is happening because the server looks up event listeners and thus has to wait for the other threads to unlock the singletonObjects. Any ideas? |
Will have a look on Monday |
I've updated my example at https://github.com/tobiasschaefer/micronaut-parallel-bug by updating to 1.3.5 (and also tried 2.0.0.BUILD-SNAPSHOT). I also removed the All commits I've seen about this issue from @jameskleeh and @graemerocher are on branches. Is it more difficult that expected? Is there any way I can support you? I'd like to see a fix in 2.0.0. |
I submitted a PR but the PR makes a compromise which may compromise the integrity of the application context. Essentially in order for beans to be allowed to be created in parallel we would need to not synchronize on the Since
|
@graemerocher : Thanks for that detailed response. I haven't got Do you have an example where In my opinion IMHO, it would be a pitty if this feature would be removed again. |
Hi @graemerocher , hi @jameskleeh , this issue is still open and relevant for me. It would probably make https://github.com/camunda-community-hub/micronaut-camunda-bpm have a faster startup time - which would be a nice added value compared to the available Spring Boot solution (especially when running a test-suite containing integration tests which might spin up the application multiple times). To recap the problem: I have two beans which are both annotated with I've recreated a simple example based on Micronaut 3.3.0, see https://github.com/tobiasschaefer/micronaut-parallel-bug-mn330 I've simplified the example to use simple beans instead of factory beans and it is based on the code from your test-suite at https://github.com/micronaut-projects/micronaut-core/blob/3.3.x/inject-java/src/test/groovy/io/micronaut/inject/parallel/ParallelBean.java I know that In https://github.com/micronaut-projects/micronaut-core/blob/3.3.x/inject/src/main/java/io/micronaut/context/DefaultBeanContext.java#L2463 there is a synchronization which prevents the parallel execution: (I think @jameskleeh is referring to that in his comment) synchronized (singletonObjects) {
loadContextScopeBean(beanDefinition);
} What is your opinion on this? Can you provide a working example where beans are actually initialized in parallel? |
Task List
Steps to Reproduce
Expected Behaviour
In the class temp.Foo there are two factory beans, both annotated with @parallel and a Thread.sleep(5000).
I expect a startup time of a bit more that 5 seconds because both should be executed in parallel.
Actual Behaviour
I see a startup time of a bit more than 10 seconds.
@jameskleeh said "Yeah it looks like there is a synchronization block where there shouldn’t be
Can you file an issue?"
Environment Information
Example Application
https://github.com/tobiasschaefer/micronaut-parallel-bug
The text was updated successfully, but these errors were encountered: