Symptoms
Since upgrading to 2023.2.0.0 (or later version) System_ProcessKeepClauses goes to error with following message in stderr.log output:
ERROR 2023-09-29 04:13:21,382 GMT [Redwood Job Thread Pool: GLOBAL.System.System worker 0] job.System_ProcessKeepClauses.815667401 - Failed to complete processDefaultRetentionOnJobs
java.lang.NullPointerException
Cause
The issue arise when your environments has been to 9.2.9.1 while some of your recurrence where using MST. HST or EST TimeZone.
9.2.9.1 had remove those TimeZone from processes while keeping the recurrence active.
In release 2023.2.0.0 an underlying change to ProcessKeepClause resulted in failing if recurrence had no TimZone define.
Affected version
2023.2.0.0 onward
Resolution
Submit below script in Scripting -> Shell
The script will find any recurrence where the TimeZone is not properly set (null) and will correct it.
By default no modification is saved, please modify boolean persist=false;
to boolean persist=True;
when you are happy with the output and want the modification to be applied.
import java.util.Iterator;
import com.redwood.scheduler.api.model.*;
{
String queryJobs = "select j.* from Job j, JobGroup jg where jg.LatestJob = j.UniqueId and jg.Status in ('A','H') and jg.JobTimeZone is null";
boolean persist=false;
int jCounter = 0;
int batchSize=200;
if(!persist) jcsOut.println("This is a test run, no modification will be done!");
for(Iterator<Job> jobs = jcsSession.executeObjectQuery(Job.TYPE, queryJobs); jobs.hasNext();){
Job job = jobs.next();
JobDefinition jd = job.getJobDefinition();
TimeZone tz = jcsSession.getTimeZoneByName("GMT");
//collect all the TZ data from oldest job in the recurrence
String oldestJobTZName;
Iterator<Job> oldestJobIt = jcsSession.executeObjectQuery(Job.TYPE,"select j.* from Job j where j.JobGroup = ? order by j.UniqueId asc", job.getJobGroup().getUniqueId());
Job oldestJob = oldestJobIt.next();
TimeZone oldestJobTZ = oldestJob.getJobTimeZone();
if(null == oldestJobTZ){
oldestJobTZName = "null";
// using default tz value
} else {
oldestJobTZName = oldestJobTZ.getOlsonName();
tz = oldestJobTZ; // using oldest job Timezone for the latest job of the recurrence
}
if(oldestJobTZName.equals("EST")) tz = jcsSession.getTimeZoneByName("Etc/GMT+5");
else if(oldestJobTZName.equals("HST")) tz = jcsSession.getTimeZoneByName("Etc/GMT+10");
else if(oldestJobTZName.equals("MST")) tz = jcsSession.getTimeZoneByName("Etc/GMT+7");
job.setJobTimeZone(tz);
jCounter++;
jcsOut.println("Found process "+ jd.getName()+" ("+job.getJobId()+") without TimeZone, will modify TimeZone to: " + tz.getOlsonName() );
//persist changes in batches
if(jCounter%batchSize==0 && persist){
jcsSession.persist();
jcsOut.println("modfification done!");
}
}
if(persist) jcsSession.persist(); // final persist
jcsOut.println("Found "+ jCounter + " process without TimeZone assigned");
}
Reference
RCORE-43424
RCORE-44859
Error
When submitting System_ProcessKeepClauses in debug mode, following stack will be shown in the stderr.log output:
ERROR 2023-09-29 04:13:21,382 GMT [Redwood Job Thread Pool: GLOBAL.System.System worker 0] job.System_ProcessKeepClauses.683550 - Failed to complete processDefaultRetentionOnJobs
java.lang.NullPointerException: Cannot invoke "com.redwood.scheduler.api.model.TimeZone.getJavaTimeZone()" because "timeZone" is null
at com.redwood.scheduler.system.jobs.retention.JobGroupYearlyFrequencyCalculator.calculateJobGroupsYearlyFrequency(JobGroupYearlyFrequencyCalculator.java:54)
at com.redwood.scheduler.system.jobs.retention.JobDefaultRetentionProcessor.calculateYearlyJobRunCountForJobGroups(JobDefaultRetentionProcessor.java:199)
at com.redwood.scheduler.system.jobs.retention.JobDefaultRetentionProcessor.processDefaultRetentionOnJobs(JobDefaultRetentionProcessor.java:166)
at com.redwood.scheduler.system.jobs.ProcessKeepClauses.execute(ProcessKeepClauses.java:274)
at com.redwood.scheduler.system.jobs.ProcessKeepClauses.execute(ProcessKeepClauses.java:253)
at com.redwood.scheduler.systemjobservice.api.JobWorker.runProcessExecute(JobWorker.java:267)
at com.redwood.scheduler.systemjobservice.api.JobWorker.processExecute(JobWorker.java:204)
at com.redwood.scheduler.systemjobservice.api.JobWorker.doWork(JobWorker.java:125)
at com.redwood.scheduler.systemjobservice.api.JobWorker.doWork(JobWorker.java:64)
at com.redwood.scheduler.infrastructure.workqueue.WorkQueueWorker.run(WorkQueueWorker.java:72)
at java.base/java.lang.Thread.run(Thread.java:833)
Comments
0 comments
Please sign in to leave a comment.