Cron settings are getting lost when migrating from Job module to Job Config

Hi, I have a problem regarding to schedulers in Confluence, let me explain.
The Job module (Job module) is deprecated since Confluence 5.10. We should use Job Config (Job Config module) instead.
In our app we have used the Job module before to define schedulers, but now we would like to migrate it to Job Config. We are facing a problem, since the modified cron settings are getting lost on switching to the new module, although we use the same key for it. To be more precise, we use the same key for as the key of the old .
How did Atlassian solved it when they have migrated this?

1 Like

We have migrated most of our scheduled jobs as follow :

From

<job key="myJob"
          name="My Job"
          class="com.example.myplugin.jobs.MyJob" perClusterJob="true">
...
</job>

To

<component key="myJob" class="com.example.myplugin.jobs.MyJob"/>
<job-config name="My job" key="myJobId">
    <job key="myJob" perClusterJob="true"/>
    <schedule cron-expression="0 * * * * ?" jitterSecs="10"/>
    <managed editable="true" keepingHistory="true" canRunAdhoc="true" canDisable="true"/>
</job-config>

and updated the MyJob class to implment the JobRunner interface as described in the documentation.

In case the above example does not answer your question, @gergely.juhasz it would be extremely helpful to see what your configuration looks like.

We migrated as follow:

From

<job key="myplugin.key.myJob" name="My Job" class="com.example.myplugin.jobs.MyJob" perClusterJob="true"/>
<trigger key="myplugin.key.myJobTrigger" name="My Job Trigger">
	<job key="myplugin.key.myJob"/>
	<schedule cron-expression="0 0 4 * * ?"/>
	<managed editable="true" keepingHistory="true" canRunAdhoc="true" canDisable="true"/>
</trigger>

To

<component key="myplugin.key.myJobRunner" class="com.example.myplugin.jobs.MyJob"/>
<job-config key="myplugin.key.myJob" name="My Job">
	<job key="myplugin.key.myJobRunner" perClusterJob="true" clusteredOnly="false"/>
	<schedule cron-expression="0 0 4 * * ?"/>
	<managed editable="true" keepingHistory="true" canRunAdhoc="true" canDisable="true"/>
</job-config>

The new scheduler also works as expected. The problem is that if we modified the cron settings via the UI before the migration, those settings will be lost and reverted to default (as defined here).

The data-loss is caused by different keys in Bandana table. With the old Job module, the scheduler configurations were getting saved to the Bandana table with BANDANAKEY prefixed with package (group) literal, like
myplugin.key#myplugin.key.myJob
while the new module makes hard-coded “DEFAULT” prefix, like this:
DEFAULT#myplugin.key.myJob

Therefore the new Job Config module won’t find the previous configuration in the Bandana table.

This problem only occurs if you had used prefixed keys before.
I digged into the source code and realized that this “DEFAULT” group name is hard-coded in com.atlassian.confluence.schedule.ScheduledJobKey and there is no option to change.