You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Background:
We have 2 types of agenda jobs running
Monitor Job(scheduled every 30 min) - This job apply changes(change in schedule time, enable or disable a job) in the jobs based on some event
Worker Job(let say scheduled every hour) - This is a job which is having some business logic and its scheduling is managed by the above Monitor job
Problem:
When the Worker and Monitor jobs are running simultaneously and if the Monitor job tries to disable the Worker Job with agenda.disable({name: "worker-job"})
The job gets updated with the disabled: true flag in the agenda collection but this flag gets overridden by the agenda when the Worker Job execution gets completed which makes the Worker job run next time which we don't want
Note: We don't want to stop the current execution of the Worker job we want to control the future run's only
Solutions we thought and rejected
In Monitor job use agenda.drain() to drain the agenda queue before disabling the job and once the job is disabled we set the agenda.processEvery() again
Rejected above approach because of 2 reasons:
We could have multiple instances of the application(which contains Monitor and Worker Job)
Since Monitor Job is an agenda job agenda.drain() will lead us to deadlock
Any help on disabling the running agenda job will be helpful.
The text was updated successfully, but these errors were encountered:
cancel the job and then stop the job instance(if the job instance is created for that job only)
By cancelling, the job record is removed from db.
If any other server is running the job. The job will not get created as the findoneandupdate query is triggered with upsert false.
Background:
We have 2 types of agenda jobs running
Problem:
agenda.disable({name: "worker-job"})
The job gets updated with the
disabled: true
flag in the agenda collection but this flag gets overridden by the agenda when the Worker Job execution gets completed which makes the Worker job run next time which we don't wantNote: We don't want to stop the current execution of the Worker job we want to control the future run's only
Solutions we thought and rejected
In Monitor job use
agenda.drain()
to drain the agenda queue before disabling the job and once the job is disabled we set the agenda.processEvery() againRejected above approach because of 2 reasons:
agenda.drain()
will lead us to deadlockAny help on disabling the running agenda job will be helpful.
The text was updated successfully, but these errors were encountered: