Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-25288

Only the first scheduler job of a page gets its status saved and is registered automatically

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Fix
    • Major
    • None
    • 17.10.0
    • Scheduler
    • None
    • Unknown
    • N/A
    • N/A

    Description

      A page can hold several XWiki.SchedulerJobClass objects, and the scheduler script API supports it ($xwiki.scheduler.scheduleJobs($doc) schedules all of them). However the scheduler only handles the first job object of a page correctly:

      • The status of any job is saved on the first job of the page. Scheduling, pausing, resuming or unscheduling the 2nd job of a page writes the new status (Normal, Paused, None) in the status property of the 1st job object, and leaves the status of the 2nd job unchanged.
      • Only the first job of the page is registered automatically. When a page holding several jobs with the Normal or Paused status is created, only its first job is registered in the scheduler. The same happens at startup when the existing jobs are restored, so a 2nd job scheduled with scheduleJobs silently stops running after a restart. Deleting or modifying a job other than the first one is not taken into account either.

      Steps to reproduce

      1. Create a page with 2 XWiki.SchedulerJobClass objects, the 1st one with the status None and the 2nd one with an empty status
      2. Schedule the 2nd job, e.g. with $xwiki.scheduler.scheduleJob($doc.getObject('XWiki.SchedulerJobClass', 1))
      3. Look at the objects of the page: the 1st job now has the Normal status while it's not scheduled, and the 2nd job, which is scheduled, still has an empty status
      4. Restart XWiki: the 2nd job is not scheduled anymore

      Cause

      SchedulerPlugin#saveStatus() saves the status on jobHolder.getXObject(XWIKI_JOB_CLASSREFERENCE), i.e. the first job object of the page, instead of the object it was given. SchedulerPlugin#register(XWikiDocument) (startup) and SchedulerPlugin#onDocumentEvent() (page created/updated/deleted) also only look at the first job object of the page.

      Both behaviours were verified with unit tests based on an in-memory Quartz scheduler.

      Attachments

        Activity

          People

            vmassol Vincent Massol
            vmassol Vincent Massol
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: