Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AmishaAgrawal011 opened this issue Aug 21, 2024 · 2 comments

Comments

@AmishaAgrawal011
Copy link

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
Copy link
Contributor

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
Copy link
Author

AmishaAgrawal011 commented Aug 24, 2024

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.

@dixitdeepak dixitdeepak reopened this Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants