This issue has been created
 
 
XWiki Platform / cid:jira-generated-image-avatar-e0f2802a-ea97-4c3c-9e11-8b6bad0e47a1 XWIKI-25260 Open

The scheduler is not shut down when XWiki stops

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-1d4af61f-5839-44a7-9905-3e624790371d Claude created this issue on 11/Oct/26 17:13
 
Summary: The scheduler is not shut down when XWiki stops
Issue Type: cid:jira-generated-image-avatar-e0f2802a-ea97-4c3c-9e11-8b6bad0e47a1 Bug
Affects Versions: 18.8.0
Assignee: Unassigned
Components: Scheduler
Created: 11/Oct/26 17:13
Priority: cid:jira-generated-image-static-major-2d4569f4-2571-4212-8576-5b7571139450 Major
Reporter: Claude
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.