Scheduler does not schedule jobs without giving any error
ashokmariyala opened this issue · 11 comments
I am scheduling 4 jobs.
2 Jobs every 1 hour. (Job names: PLUGIN_DISCOVERY_JOB__18998__DISCOVERY__ and PLUGIN_DISCOVERY_JOB__19003__DISCOVERY__)
1 Job every 6 hours. (Job name: Sync_defs)
1 Job every 5 minutes. (Job name: MON_JOB__39f6f2a3-e0db-4036-90fe-74b67d1af4af__PING__5)
Following are the logs.
2021-09-29T23:45:00.022Z INFO portedapp/ported-app-processor.go:36 Received Ported App Scheduling request..!!
2021-09-29T23:45:00.029Z INFO portedapp/ported-app-processor.go:66 Successfully scheduled Job..!!
2021-09-29T23:45:00.029Z INFO portedapp/ported-app-processor.go:67 Job Name : MON_JOB__39f6f2a3-e0db-4036-90fe-74b67d1af4af__PING__5, Target : ping-adapter
2021-09-29T23:50:00.000Z INFO portedapp/ported-app-processor.go:36 Received Ported App Scheduling request..!!
2021-09-29T23:50:00.007Z INFO portedapp/ported-app-processor.go:66 Successfully scheduled Job..!!
2021-09-29T23:50:00.007Z INFO portedapp/ported-app-processor.go:67 Job Name : MON_JOB__39f6f2a3-e0db-4036-90fe-74b67d1af4af__PING__5, Target : ping-adapter
2021-09-29T23:55:00.020Z INFO portedapp/ported-app-processor.go:36 Received Ported App Scheduling request..!!
2021-09-29T23:55:00.026Z INFO portedapp/ported-app-processor.go:66 Successfully scheduled Job..!!
2021-09-29T23:55:00.027Z INFO portedapp/ported-app-processor.go:67 Job Name : MON_JOB__39f6f2a3-e0db-4036-90fe-74b67d1af4af__PING__5, Target : ping-adapter
2021-09-30T00:00:00.000Z INFO portedapp/ported-app-processor.go:36 Received Ported App Scheduling request..!!
2021-09-30T00:00:00.008Z INFO portedapp/ported-app-processor.go:66 Successfully scheduled Job..!!
2021-09-30T00:00:00.008Z INFO portedapp/ported-app-processor.go:67 Job Name : Sync_defs, Target : snmp-adapter
2021-09-30T00:06:00.023Z INFO portedapp/ported-app-processor.go:36 Received Ported App Scheduling request..!!
2021-09-30T00:06:00.029Z INFO portedapp/ported-app-processor.go:66 Successfully scheduled Job..!!
2021-09-30T00:06:00.029Z INFO portedapp/ported-app-processor.go:67 Job Name : PLUGIN_DISCOVERY_JOB__18998__DISCOVERY__, Target : snmp-adapter
2021-09-30T00:38:00.000Z INFO portedapp/ported-app-processor.go:36 Received Ported App Scheduling request..!!
2021-09-30T00:38:00.006Z INFO portedapp/ported-app-processor.go:66 Successfully scheduled Job..!!
2021-09-30T00:38:00.007Z INFO portedapp/ported-app-processor.go:67 Job Name : PLUGIN_DISCOVERY_JOB__19003__DISCOVERY__, Target : snmp-adapter
2021-09-30T01:00:00.001Z INFO portedapp/ported-app-processor.go:36 Received Ported App Scheduling request..!!
2021-09-30T01:00:00.008Z INFO portedapp/ported-app-processor.go:66 Successfully scheduled Job..!!
2021-09-30T01:00:00.008Z INFO portedapp/ported-app-processor.go:67 Job Name : MON_JOB__39f6f2a3-e0db-4036-90fe-74b67d1af4af__PING__5, Target : ping-adapter
2021-09-30T01:05:00.024Z INFO portedapp/ported-app-processor.go:36 Received Ported App Scheduling request..!!
2021-09-30T01:05:00.031Z INFO portedapp/ported-app-processor.go:66 Successfully scheduled Job..!!
2021-09-30T01:05:00.031Z INFO portedapp/ported-app-processor.go:67 Job Name : MON_JOB__39f6f2a3-e0db-4036-90fe-74b67d1af4af__PING__5, Target : ping-adapter
2021-09-30T01:06:00.024Z INFO portedapp/ported-app-processor.go:36 Received Ported App Scheduling request..!!
2021-09-30T01:06:00.029Z INFO portedapp/ported-app-processor.go:66 Successfully scheduled Job..!!
2021-09-30T01:06:00.029Z INFO portedapp/ported-app-processor.go:67 Job Name : PLUGIN_DISCOVERY_JOB__18998__DISCOVERY__, Target : snmp-adapter
2021-09-30T01:10:00.024Z INFO portedapp/ported-app-processor.go:36 Received Ported App Scheduling request..!!
2021-09-30T01:10:00.030Z INFO portedapp/ported-app-processor.go:66 Successfully scheduled Job..!!
2021-09-30T01:10:00.030Z INFO portedapp/ported-app-processor.go:67 Job Name : MON_JOB__39f6f2a3-e0db-4036-90fe-74b67d1af4af__PING__5, Target : ping-adapter
Code snippet
type ScheduledJob struct {
JobName string
Config string
}
func (sh *ScheduledJob) Description() string {
return sh.JobName
}
func (sh *ScheduledJob) Key() int {
return quartz.HashCode(sh.JobName)
}
func (sh *ScheduledJob) Execute() {
logger.SugarLogger.Info("Received Ported App Scheduling request..!!")
var request model.GenericRequest
err := json.Unmarshal([]byte(sh.Config), &request)
if err != nil {
logger.SugarLogger.Error("Error while reading generic request message. Error: ", err)
}
metaData := request.MetaData
metaData.Source = "Scheduler"
jobConfig := request.JobConfiguration
requestJson, err := json.Marshal(request)
if err != nil {
logger.SugarLogger.Error("Error while reading metadata message. Error: ", err)
}
// publish request json to app
target := metaData.Target
publishUrl := httpclient.GetPublishUrl(target)
_, err = httpclient.PostMessage(string(requestJson), publishUrl)
if err != nil {
logger.SugarLogger.Error("Error while publish message to app. App Name : ", target, ", Error:", err)
}
logger.SugarLogger.Info("Successfully scheduled Job..!! ")
logger.SugarLogger.Info("Job Name : ", jobConfig.JobName, ", Target : ", target)
}
Version: v0.3.6
In the above logs From 5 minute job not scheduled job from 2021-09-29T23:55:00.027Z to 2021-09-30T01:00:00.001Z Here 1 hour 5 minutes not scheduled any jobs.
Observation : Here request is not coming to Execute() method
It seems there might be issue in NextTriggerTime calculation. If you observer trigger times 23:55 and it is resumed back at 1:00.
@reugn Could you please verify the above issue and fix it. Thanks in advance.
@reugn Validated fix calculation of next value for minutes and hours. It is working fine. I found one more issue in weekly quartz cron.
My Cron expression is 0 0 10 ? * 1,2,4,6 *
This means At 10:00:00am, on every Sunday, Monday, Wednesday and Friday, every month
it will trigger the scheduling.
But it is triggered on Saturday and Monday. Please find following logs for your reference.
2021-10-01T11:59:36.017Z INFO sdkapp/sdk-app.go:140 Job Added/Updated Successfully..!!, Job Name : ::DISCOVERY:ADAPTER-MANIFEST-cd92ffbe
2021-10-02T10:00:00.052Z INFO sdkapp/sdk-app-processor.go:61 Job Name : ::DISCOVERY:ADAPTER-MANIFEST-cd92ffbe, Target : test_app
2021-10-04T10:00:00.030Z INFO sdkapp/sdk-app-processor.go:61 Job Name : ::DISCOVERY:ADAPTER-MANIFEST-cd92ffbe, Target : test_app
If you observe the above log. It is triggered on 2021-10-02T10:00:00.052Z
. This means 02nd October 10 AM (Saturday).
Thanks @ashokmariyala . I use the range of 0-6 (SUN-SAT) as the allowed values for the day of week
field. I will add a cron format table to the readme.
@ashokmariyala please alter your expression to 0 0 10 ? * 0,1,3,5 *
to get the desired results.
@reugn Thank you for your response. We are preparing cron expressions based on quartz cron standards. The allowed values for day of week field is 1-7 or SUN-SAT
but you have used 0-6 or SUN-SAT
.
Reference link: Cron Trigger Format
Are you going to support as per quartz cron standards?
@ashokmariyala switched to the Quartz format.
Thanks, @reugn. I will validate the fix and let you know.
Hi @reugn
Validated your fix and it is working fine. Thanks for your quick support. Would you please create a newer version with your fixes.
@ashokmariyala v0.3.7 was released.
@reugn Thank you