hotwax / OrderRouting

Order Routing
Apache License 2.0
0 stars 1 forks source link

Updating the cron expression of any routing job triggers an immediate run of the job. #45

Open AmishaAgrawal011 opened 2 months ago

AmishaAgrawal011 commented 2 months ago

When modifying the cron expression for any job in the routing system, the job starts executing immediately upon saving the new cron expression, instead of waiting for the next scheduled time according to the updated expression.

Steps to Reproduce: Navigate to the job configuration screen in the Marg Select any job and update its cron expression to a new value. Save the changes. Observe that the job runs immediately after saving, instead of waiting for the next scheduled time.

Expected Behavior: The job should not run immediately after updating the cron expression. It should wait until the next scheduled time as per the new cron expression.

Actual Behavior: The job runs immediately after the cron expression is updated.

Impact: This issue could lead to unintended job executions, potentially affecting system stability and causing disruptions in the routing process.

dixitdeepak commented 2 months ago

As per the schedule job runner, if the service job's last scheduled time is before its last run time, the system won’t execute the job. However, if the cron expression is updated and the new scheduled time is set to be later than the previous scheduled time, the system will compare the new scheduled time with the last run time. If the new scheduled time is after the last run time, the system will proceed to execute the job.

Example: If a service is scheduled to run at 9:00 AM, the system executes the job at 9:00:10 AM, and then the cron expression is updated to 9:05 AM, the system will compare the new scheduled time (9:05 AM) with the last run time (9:00:10 AM). Since the new scheduled time is after the last run time, the system will execute the service job.

AmishaAgrawal011 commented 2 months ago

Testcase 1: when a paused job is enabled with a new cron expression, the system executes the job immediately.

Scenario: Paused Job Executed Immediately Upon Enabling with a New Schedule

Job Status Before: Paused Enable Job Time: 9:00 AM New Cron Expression: 10:00 AM

Expected Behaviour: The system should execute the job on the scheduled time (10:00 AM)

Result: Failed. The job executed immediately after being enabled.

Testcase 2: Validate the execution behaviour when rescheduling a job to an earlier time.

Scenario: The job does not execute immediately when rescheduled to an earlier time if the last run time is after the new scheduled time.

Job Status Before: Active Scheduled Job Time: 8:00 AM New Cron Expression: 7:00 AM

Expected Behaviour: The system should execute the job on the scheduled time (7:00 AM)

Result: Failed. The job executed immediately after being updated.