Skip to content
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

ApplicationContext very slow to shutdown with bean of type org.springframework.scheduling.quartz.SchedulerFactoryBean [SPR-6354] #11020

Closed
spring-projects-issues opened this issue Nov 13, 2009 · 3 comments
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Nov 13, 2009

David Gageot opened SPR-6354 and commented

The following code takes less than a second to run with version 3.0RC1. With 3.0RC2, it takes more than 30s.

The problem seems to come from the combination of SchedulerFactoryBean and lazy=true.
With lazy=false, everything is ok.

ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
Object bean = context.getBean("quartzScheduler");
context.destroy();

<bean id="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="true" />
Here is the output log:
Nov 13, 2009 11:05:17 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@5265a77f: startup date [Fri Nov 13 23:05:17 CET 2009]; root of context hierarchy
Nov 13, 2009 11:05:17 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [applicationContext.xml]
Nov 13, 2009 11:05:18 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@8888e6c: defining beans [quartzScheduler]; root of factory hierarchy
Nov 13, 2009 11:05:18 PM org.quartz.core.SchedulerSignalerImpl <init>
INFO: Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
Nov 13, 2009 11:05:18 PM org.quartz.core.QuartzScheduler <init>
INFO: Quartz Scheduler v.1.6.2 created.
Nov 13, 2009 11:05:18 PM org.quartz.simpl.RAMJobStore initialize
INFO: RAMJobStore initialized.
Nov 13, 2009 11:05:18 PM org.quartz.impl.StdSchedulerFactory instantiate
INFO: Quartz scheduler 'quartzScheduler' initialized from an externally provided properties instance.
Nov 13, 2009 11:05:18 PM org.quartz.impl.StdSchedulerFactory instantiate
INFO: Quartz scheduler version: 1.6.2
Nov 13, 2009 11:05:18 PM org.quartz.core.QuartzScheduler setJobFactory
INFO: JobFactory set to: org.springframework.scheduling.quartz.AdaptableJobFactory@49938039
Nov 13, 2009 11:05:18 PM org.springframework.context.support.AbstractApplicationContext doClose
INFO: Closing org.springframework.context.support.ClassPathXmlApplicationContext@5265a77f: startup date [Fri Nov 13 23:05:17 CET 2009]; root of context hierarchy
Nov 13, 2009 11:05:48 PM org.springframework.context.support.DefaultLifecycleProcessor$ShutdownGroup shutdown
WARNING: failed to shutdown beans with order 2147483647 within timeout of 30000
Nov 13, 2009 11:05:48 PM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@8888e6c: defining beans [quartzScheduler]; root of factory hierarchy
Nov 13, 2009 11:05:48 PM org.springframework.scheduling.quartz.SchedulerFactoryBean destroy
INFO: Shutting down Quartz Scheduler
Nov 13, 2009 11:05:48 PM org.quartz.core.QuartzScheduler shutdown
INFO: Scheduler quartzScheduler_$_NON_CLUSTERED shutting down.
Nov 13, 2009 11:05:48 PM org.quartz.core.QuartzScheduler standby
INFO: Scheduler quartzScheduler_$_NON_CLUSTERED paused.
Nov 13, 2009 11:05:48 PM org.quartz.core.QuartzScheduler shutdown
INFO: Scheduler quartzScheduler_$_NON_CLUSTERED shutdown complete.


Affects: 3.0 RC2

Issue Links:

Referenced from: commits c6f3613

@spring-projects-issues
Copy link
Collaborator Author

Mark Fisher commented

Apparently with lazy="true", the CountDownLatch is not being called. I'm looking into that.

One other workaround for the moment would be to register your own bean named "lifecycleProcessor" of type DefaultLifecycleProcessor. Then you can set a lower value for the "timeout" property (its default is 30 seconds).

@spring-projects-issues
Copy link
Collaborator Author

Mark Fisher commented

As a side note, we might not want to bother waiting on the latch for the Integer.MAX_VALUE group in the first place.

@spring-projects-issues
Copy link
Collaborator Author

Mark Fisher commented

This actually triggered the resolution of a more general issue. The DefaultLifecycleProcessor was waiting on all SmartLifecycle beans to stop, but it was only calling stop(callback) for those that were already running. So, now I am counting down the latch for any SmartLifecycle bean that is not even running in the first place.

I added a couple test cases for the specific Quartz scheduler case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant