Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
18.8.0
-
None
-
Unknown
-
Description
Problem
Nothing stops the Quartz scheduler used by the Scheduler plugin when XWiki stops: SchedulerPlugin never calls Scheduler#shutdown(). As a consequence:
- the scheduler keeps firing jobs while XWiki is stopping, so a job can start while the components, the caches and the database access it needs are being disposed, and fail with errors unrelated to the job;
- a job which is running when XWiki stops is not given any chance to finish before the components it uses are disposed;
- when the web application is stopped or reloaded without stopping the JVM (for example a redeployment in the servlet container), the scheduler of the previous instance and its threads are never released. The scheduler threads are daemon threads, which only helps when the whole JVM exits.
The code was read on 18.8.0, but the behaviour is much older: the plugin never stopped its scheduler.
Proposal
When the application stops (ApplicationStoppedEvent, which is sent before the components are disposed), the plugin:
- puts the scheduler in standby, so that no new job is fired;
- waits for the running jobs to finish, for at most 30 seconds, and logs the jobs which are still running at the end of the wait;
- shuts down the scheduler and its threads.
A scheduler which is still being initialized is not started anymore once the application is stopping.
Attachments
Issue Links
- is related to
-
XWIKI-25262 Run the scheduler on a single cluster member and move it when that member leaves
-
- Open
-